Skip to content

Commit 8f4f32d

Browse files
committed
Move esc dismiss modal logic to GetStateForActionHandlers
1 parent 1aaef3d commit 8f4f32d

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/libs/Navigation/AppNavigator/createRootStackNavigator/GetStateForActionHandlers.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,23 @@ function handleDismissModalAction(
146146
stackRouter: Router<StackNavigationState<ParamListBase>, CommonActions.Action | StackActionType>,
147147
) {
148148
const lastRoute = state.routes.at(-1);
149-
const newAction = StackActions.pop();
150149

151150
if (!lastRoute?.name || !MODAL_ROUTES_TO_DISMISS.includes(lastRoute?.name)) {
152151
Log.hmmm('[Navigation] dismissModal failed because there is no modal stack to dismiss');
153152
return null;
154153
}
155154

155+
let newAction = StackActions.pop();
156+
157+
if (lastRoute?.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR) {
158+
const rhpRoutes = lastRoute?.state?.routes;
159+
// This handles closing the modal when wide rhp is visible
160+
if (rhpRoutes?.at(0)?.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT && rhpRoutes?.length > 1) {
161+
newAction = {...StackActions.popToTop(), target: lastRoute.state?.key};
162+
return;
163+
}
164+
}
165+
156166
return stackRouter.getStateForAction(state, newAction, configOptions);
157167
}
158168

0 commit comments

Comments
 (0)