Skip to content

Commit ddef0ba

Browse files
authored
Merge pull request Expensify#88949 from dmkt9/fix/settings-wallet-appears
fix: The Wallet Settings page is displayed instead of the settings menu page after opening "Add address" modal on the Home page on mobile web
2 parents d36e0b0 + d46e9ac commit ddef0ba

1 file changed

Lines changed: 31 additions & 10 deletions

File tree

  • src/libs/Navigation/helpers/linkTo

src/libs/Navigation/helpers/linkTo/index.ts

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,18 +204,39 @@ export default function linkTo(navigation: NavigationContainerRef<RootNavigatorP
204204
// Full-screen routes only exist inside TAB_NAVIGATOR, so look at the active tab directly.
205205
const tabRoute = currentState.routes.findLast((route) => route.name === NAVIGATORS.TAB_NAVIGATOR);
206206
const tabState = tabRoute ? getTabState(tabRoute as NavigationPartialRoute) : undefined;
207+
const tabNavigatorStateKey = tabRoute?.state?.key;
207208
const lastFullScreenRoute = tabState?.routes?.at(tabState.index ?? 0) as NavigationPartialRoute | undefined;
208209
if (matchingFullScreenRoute && lastFullScreenRoute && shouldChangeToMatchingFullScreen(newFocusedRoute, matchingFullScreenRoute, lastFullScreenRoute)) {
209-
// Navigate within the existing TAB_NAVIGATOR (tab switch) rather than pushing a new one.
210-
const lastRouteInMatchingFullScreen = matchingFullScreenRoute.state?.routes?.at(-1);
211-
const additionalAction = CommonActions.navigate({
212-
name: NAVIGATORS.TAB_NAVIGATOR,
213-
params: {
214-
screen: matchingFullScreenRoute.name,
215-
params: lastRouteInMatchingFullScreen ? {screen: lastRouteInMatchingFullScreen.name, params: lastRouteInMatchingFullScreen.params} : matchingFullScreenRoute.params,
216-
},
217-
});
218-
navigation.dispatch(additionalAction);
210+
const matchingFullScreenRouteInTabRootState = tabState?.routes?.find((route) => route.name === matchingFullScreenRoute.name);
211+
if (matchingFullScreenRouteInTabRootState && matchingFullScreenRouteInTabRootState.state === undefined) {
212+
// If matchingFullScreenRoute state is uninitialized (has never been visited)
213+
// Dispatch matchingFullScreenRoute as well so that its sidebarScreen route is added to the stack
214+
const additionalAction: StackNavigationAction = {
215+
type: CONST.NAVIGATION.ACTION_TYPE.NAVIGATE,
216+
payload: {
217+
name: matchingFullScreenRoute.name,
218+
params: {
219+
...(matchingFullScreenRoute.params ?? {}),
220+
...(matchingFullScreenRoute.state ? {state: matchingFullScreenRoute.state} : {}),
221+
},
222+
},
223+
target: tabNavigatorStateKey,
224+
};
225+
navigation.dispatch(additionalAction);
226+
} else {
227+
// Navigate within the existing TAB_NAVIGATOR (tab switch) rather than pushing a new one.
228+
const lastRouteInMatchingFullScreen = matchingFullScreenRoute.state?.routes?.at(-1);
229+
const additionalAction = CommonActions.navigate({
230+
name: NAVIGATORS.TAB_NAVIGATOR,
231+
params: {
232+
screen: matchingFullScreenRoute.name,
233+
params: lastRouteInMatchingFullScreen
234+
? {screen: lastRouteInMatchingFullScreen.name, params: lastRouteInMatchingFullScreen.params}
235+
: matchingFullScreenRoute.params,
236+
},
237+
});
238+
navigation.dispatch(additionalAction);
239+
}
219240
}
220241
}
221242
}

0 commit comments

Comments
 (0)