Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/libs/Navigation/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,25 @@ function goBack(fallbackRoute?: Route, shouldEnforceFallback = false, shouldPopT
navigationRef.current.goBack();
}

/**
* Close the current screen and navigate to the route.
* If the current screen is the first screen in the navigator, we force using the fallback route to replace the current screen.
* It's useful in a case where we want to close an RHP and navigate to another RHP to prevent any blink effect.
*/
function closeAndNavigate(route: Route) {
if (!navigationRef.current) {
return;
}

const isFirstRouteInNavigator = !getActiveRouteIndex(navigationRef.current.getState());
if (isFirstRouteInNavigator) {
goBack(route, true);
return;
}
goBack();
navigate(route);
}

/**
* Reset the navigation state to Home page
*/
Expand Down Expand Up @@ -396,6 +415,7 @@ export default {
isActiveRoute,
getActiveRoute,
getActiveRouteWithoutParams,
closeAndNavigate,
goBack,
isNavigationReady,
setIsNavigationReady,
Expand Down
3 changes: 1 addition & 2 deletions src/pages/iou/request/step/IOURequestStepCategory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ function IOURequestStepCategory({
IOU.setMoneyRequestCategory(transactionID, updatedCategory);

if (action === CONST.IOU.ACTION.CATEGORIZE) {
Navigation.goBack();
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(action, iouType, transactionID, report?.reportID ?? '-1'));
Navigation.closeAndNavigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(action, iouType, transactionID, report?.reportID ?? '-1'));
return;
}

Expand Down