@sigmela/router 0.3.3 → 0.3.4
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.
|
@@ -124,9 +124,11 @@ export const RenderDrawer = /*#__PURE__*/memo(({
|
|
|
124
124
|
useEffect(() => {
|
|
125
125
|
const key = tabs[index]?.tabKey;
|
|
126
126
|
if (key) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
startTransition(() => {
|
|
128
|
+
setVisited(prev => prev[key] ? prev : {
|
|
129
|
+
...prev,
|
|
130
|
+
[key]: true
|
|
131
|
+
});
|
|
130
132
|
});
|
|
131
133
|
}
|
|
132
134
|
}, [tabs, index]);
|
package/lib/module/Navigation.js
CHANGED
|
@@ -11,7 +11,9 @@ function useStackHistory(router, stackId) {
|
|
|
11
11
|
const [history, setHistory] = useState(() => stackId ? router.getStackHistory(stackId) : EMPTY_HISTORY);
|
|
12
12
|
useEffect(() => {
|
|
13
13
|
if (!stackId) {
|
|
14
|
-
|
|
14
|
+
startTransition(() => {
|
|
15
|
+
setHistory(EMPTY_HISTORY);
|
|
16
|
+
});
|
|
15
17
|
return;
|
|
16
18
|
}
|
|
17
19
|
const update = () => {
|
|
@@ -176,6 +176,20 @@ export const RenderTabBar = /*#__PURE__*/memo(({
|
|
|
176
176
|
index,
|
|
177
177
|
config
|
|
178
178
|
} = snapshot;
|
|
179
|
+
|
|
180
|
+
// Local focus state driven by startTransition so that isFocused changes
|
|
181
|
+
// are deferred until the native Fragment lifecycle completes (Android Fabric).
|
|
182
|
+
const [focusedTabKey, setFocusedTabKey] = useState(() => tabs[index]?.tabKey);
|
|
183
|
+
|
|
184
|
+
// Sync focusedTabKey when index changes from external sources (programmatic navigation).
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
const key = tabs[index]?.tabKey;
|
|
187
|
+
if (key && key !== focusedTabKey) {
|
|
188
|
+
startTransition(() => {
|
|
189
|
+
setFocusedTabKey(key);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}, [tabs, index, focusedTabKey]);
|
|
179
193
|
const {
|
|
180
194
|
iconColor,
|
|
181
195
|
iconColorActive,
|
|
@@ -199,7 +213,10 @@ export const RenderTabBar = /*#__PURE__*/memo(({
|
|
|
199
213
|
const tabIndex = tabs.findIndex(route => route.tabKey === tabKey);
|
|
200
214
|
if (tabIndex === -1) return;
|
|
201
215
|
|
|
202
|
-
//
|
|
216
|
+
// Defer isFocused update so the native Fragment has time to attach.
|
|
217
|
+
startTransition(() => {
|
|
218
|
+
setFocusedTabKey(tabKey);
|
|
219
|
+
});
|
|
203
220
|
if (tabIndex !== index) {
|
|
204
221
|
tabBar.onIndexChange(tabIndex);
|
|
205
222
|
}
|
|
@@ -355,7 +372,7 @@ export const RenderTabBar = /*#__PURE__*/memo(({
|
|
|
355
372
|
experimentalControlNavigationStateInJS: config.experimentalControlNavigationStateInJS,
|
|
356
373
|
...containerProps,
|
|
357
374
|
children: tabs.map((tab, i) => {
|
|
358
|
-
const isFocused = tab.tabKey ===
|
|
375
|
+
const isFocused = tab.tabKey === focusedTabKey;
|
|
359
376
|
const stack = tabBar.stacks[tab.tabKey];
|
|
360
377
|
const node = tabBar.nodes[tab.tabKey];
|
|
361
378
|
const Screen = tabBar.screens[tab.tabKey];
|