Skip to content

Commit

Permalink
Merge pull request #23007 from adamgrzybowski/@swm/navigation-refacto…
Browse files Browse the repository at this point in the history
…r-multiple-rhp-flows

[navigation-refactor] Fix: dont use fallback if there are multiple rhp stacks
  • Loading branch information
mountiny authored Jul 20, 2023
2 parents 210ec79 + 6ca9f4a commit 82fd2f9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/libs/Navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,19 @@ function goBack(fallbackRoute = ROUTES.HOME, shouldEnforceFallback = false, shou
return;
}

if (shouldEnforceFallback || (!getActiveRouteIndex(navigationRef.current.getState()) && fallbackRoute)) {
const isFirstRouteInNavigator = !getActiveRouteIndex(navigationRef.current.getState());

if (isFirstRouteInNavigator) {
const rootState = navigationRef.getRootState();
const lastRoute = _.last(rootState.routes);
// If the user comes from a different flow (there is more than one route in RHP) we should go back to the previous flow on UP button press instead of using the fallbackRoute.
if (lastRoute.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR && lastRoute.state.index > 0) {
navigationRef.current.goBack();
return;
}
}

if (shouldEnforceFallback || (isFirstRouteInNavigator && fallbackRoute)) {
navigate(fallbackRoute, 'UP');
return;
}
Expand Down

0 comments on commit 82fd2f9

Please sign in to comment.