@applicaster/zapp-react-native-utils 17.0.0-rc.1 → 17.0.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,6 +36,39 @@ describe("focusManager", () => {
36
36
  expect(mockSetFocus).toBeCalledWith(null, undefined);
37
37
  });
38
38
 
39
+ it("restores focus when the previously focused item re-registers", () => {
40
+ const id = "player-controls-toggle-play-pause";
41
+
42
+ const makeComponent = (setFocus) => ({
43
+ setFocus,
44
+ setBlur: function () {},
45
+ blur: function () {},
46
+ willReceiveFocus: function () {},
47
+ willLoseFocus: function () {},
48
+ hasLostFocus: function () {},
49
+ isMounted: function () {
50
+ return true;
51
+ },
52
+ props: { id },
53
+ });
54
+
55
+ focusManager.register({ id, component: makeComponent(jest.fn()) });
56
+ focusManager.setFocus(id);
57
+ expect(focusManager.getCurrentFocus()?.props?.id).toBe(id);
58
+
59
+ // transport controls auto-hide: the focused button unmounts
60
+ focusManager.unregister(id);
61
+ expect(focusManager.getCurrentFocus()).toBeNull();
62
+
63
+ // user presses a key, controls become visible again and the button remounts
64
+ const remountedSetFocus = jest.fn();
65
+
66
+ focusManager.register({ id, component: makeComponent(remountedSetFocus) });
67
+
68
+ expect(focusManager.getCurrentFocus()?.props?.id).toBe(id);
69
+ expect(remountedSetFocus).toBeCalledTimes(1);
70
+ });
71
+
39
72
  describe("register", () => {});
40
73
  describe("unregister", () => {});
41
74
  describe("find", () => {});
@@ -472,7 +472,7 @@ export const focusManager = (function () {
472
472
  focusableTree.addNode({ id, component });
473
473
 
474
474
  if (!currentFocusNode && id === lastFocusedId && !id.includes("menu")) {
475
- setFocus(focusableTree.findInTree(id));
475
+ setFocus(id);
476
476
  }
477
477
 
478
478
  return component;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "17.0.0-rc.1",
3
+ "version": "17.0.0-rc.3",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "homepage": "https://github.com/applicaster/quickbrick#readme",
29
29
  "dependencies": {
30
- "@applicaster/applicaster-types": "17.0.0-rc.1",
30
+ "@applicaster/applicaster-types": "17.0.0-rc.3",
31
31
  "buffer": "^5.2.1",
32
32
  "camelize": "^1.0.0",
33
33
  "dayjs": "^1.11.10",