From 330fa2cd83e24b73c981e6789404ae984272f671 Mon Sep 17 00:00:00 2001 From: s-alves10 Date: Wed, 11 Oct 2023 18:35:27 -0500 Subject: [PATCH 1/2] fix: close not-found page when dismissing modal --- src/libs/Navigation/Navigation.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/Navigation/Navigation.js b/src/libs/Navigation/Navigation.js index 912e7b23b3dc..e57d879035f5 100644 --- a/src/libs/Navigation/Navigation.js +++ b/src/libs/Navigation/Navigation.js @@ -167,11 +167,16 @@ function dismissModal(targetReportID) { case SCREENS.REPORT_ATTACHMENTS: // if we are not in the target report, we need to navigate to it after dismissing the modal if (targetReportID && targetReportID !== getTopmostReportId(rootState)) { - const state = getStateFromPath(ROUTES.REPORT_WITH_ID.getRoute(targetReportID)); + const state = getStateFromPath(ROUTES.getReportRoute(targetReportID)); const action = getActionFromState(state, linkingConfig.config); action.type = 'REPLACE'; navigationRef.current.dispatch(action); + // If not-found page is in the route stack, we need to close it + } else if (targetReportID && _.some(rootState.routes, route => route.name === SCREENS.NOT_FOUND)) { + const lastRouteIndex = rootState.routes.length - 1; + const centralRouteIndex = _.findLastIndex(rootState.routes, route => route.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR); + navigationRef.current.dispatch({...StackActions.pop(lastRouteIndex - centralRouteIndex), target: rootState.key}); } else { navigationRef.current.dispatch({...StackActions.pop(), target: rootState.key}); } From 63ca5c08dc78ff0c270c10cd83464edca4f26d72 Mon Sep 17 00:00:00 2001 From: s-alves10 Date: Wed, 11 Oct 2023 19:09:47 -0500 Subject: [PATCH 2/2] fix: prettier --- src/libs/Navigation/Navigation.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/Navigation/Navigation.js b/src/libs/Navigation/Navigation.js index e57d879035f5..503d9fc8251a 100644 --- a/src/libs/Navigation/Navigation.js +++ b/src/libs/Navigation/Navigation.js @@ -167,15 +167,15 @@ function dismissModal(targetReportID) { case SCREENS.REPORT_ATTACHMENTS: // if we are not in the target report, we need to navigate to it after dismissing the modal if (targetReportID && targetReportID !== getTopmostReportId(rootState)) { - const state = getStateFromPath(ROUTES.getReportRoute(targetReportID)); + const state = getStateFromPath(ROUTES.REPORT_WITH_ID.getRoute(targetReportID)); const action = getActionFromState(state, linkingConfig.config); action.type = 'REPLACE'; navigationRef.current.dispatch(action); - // If not-found page is in the route stack, we need to close it - } else if (targetReportID && _.some(rootState.routes, route => route.name === SCREENS.NOT_FOUND)) { + // If not-found page is in the route stack, we need to close it + } else if (targetReportID && _.some(rootState.routes, (route) => route.name === SCREENS.NOT_FOUND)) { const lastRouteIndex = rootState.routes.length - 1; - const centralRouteIndex = _.findLastIndex(rootState.routes, route => route.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR); + const centralRouteIndex = _.findLastIndex(rootState.routes, (route) => route.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR); navigationRef.current.dispatch({...StackActions.pop(lastRouteIndex - centralRouteIndex), target: rootState.key}); } else { navigationRef.current.dispatch({...StackActions.pop(), target: rootState.key});