Skip to content

Commit

Permalink
Merge pull request Expensify#41472 from bernhardoj/fix/40801-double-n…
Browse files Browse the repository at this point in the history
…avigation-when-closing-attachment-modal

Fix user is navigated to IOU report when dismissing receipt modal with ESC key
  • Loading branch information
marcochavezf authored May 10, 2024
2 parents 0940378 + c970341 commit 390e2a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/components/Modal/BaseModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ function BaseModal(
*/
const hideModal = useCallback(
(callHideCallback = true) => {
Modal.willAlertModalBecomeVisible(false);
if (shouldSetModalVisibility) {
Modal.setModalVisibility(false);
if (Modal.areAllModalsHidden()) {
Modal.willAlertModalBecomeVisible(false);
if (shouldSetModalVisibility) {
Modal.setModalVisibility(false);
}
}
if (callHideCallback) {
onModalHide();
Expand Down
6 changes: 5 additions & 1 deletion src/libs/actions/Modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,8 @@ function willAlertModalBecomeVisible(isVisible: boolean, isPopover = false) {
Onyx.merge(ONYXKEYS.MODAL, {willAlertModalBecomeVisible: isVisible, isPopover});
}

export {setCloseModal, close, onModalDidClose, setModalVisibility, willAlertModalBecomeVisible, setDisableDismissOnEscape, closeTop};
function areAllModalsHidden() {
return closeModals.length === 0;
}

export {setCloseModal, close, onModalDidClose, setModalVisibility, willAlertModalBecomeVisible, setDisableDismissOnEscape, closeTop, areAllModalsHidden};
2 changes: 1 addition & 1 deletion src/pages/TransactionReceiptPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function TransactionReceipt({transaction, report, reportMetadata = {isLoadingIni
originalFileName={receiptURIs?.filename}
defaultOpen
onModalClose={() => {
Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report?.reportID ?? ''));
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(report?.reportID ?? ''));
}}
isLoading={!transaction && reportMetadata?.isLoadingInitialReportActions}
shouldShowNotFoundPage={shouldShowNotFoundPage}
Expand Down

0 comments on commit 390e2a8

Please sign in to comment.