From 3c24ca43ad2c81cdcc484d475481c344d5a8864e Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 2 May 2024 11:14:10 +0800 Subject: [PATCH 1/3] don't set modal visibility when there is another modal still visible --- src/components/Modal/BaseModal.tsx | 8 +++++--- src/libs/actions/Modal.ts | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/Modal/BaseModal.tsx b/src/components/Modal/BaseModal.tsx index 38701389f78b..89b7afce617d 100644 --- a/src/components/Modal/BaseModal.tsx +++ b/src/components/Modal/BaseModal.tsx @@ -75,9 +75,11 @@ function BaseModal( */ const hideModal = useCallback( (callHideCallback = true) => { - Modal.willAlertModalBecomeVisible(false); - if (shouldSetModalVisibility) { - Modal.setModalVisibility(false); + if (Modal.getModalVisibleCount() === 0) { + Modal.willAlertModalBecomeVisible(false); + if (shouldSetModalVisibility) { + Modal.setModalVisibility(false); + } } if (callHideCallback) { onModalHide(); diff --git a/src/libs/actions/Modal.ts b/src/libs/actions/Modal.ts index 7de4548b92c9..5b907655cc3b 100644 --- a/src/libs/actions/Modal.ts +++ b/src/libs/actions/Modal.ts @@ -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 getModalVisibleCount() { + return closeModals.length; +} + +export {setCloseModal, close, onModalDidClose, setModalVisibility, willAlertModalBecomeVisible, setDisableDismissOnEscape, closeTop, getModalVisibleCount}; From 2be83998736ce78903c7fecf098bb2e6da5cf874 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 2 May 2024 11:14:18 +0800 Subject: [PATCH 2/3] change fallback route --- src/pages/TransactionReceiptPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/TransactionReceiptPage.tsx b/src/pages/TransactionReceiptPage.tsx index 7a2df49e287a..eff94119ea2b 100644 --- a/src/pages/TransactionReceiptPage.tsx +++ b/src/pages/TransactionReceiptPage.tsx @@ -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} From c9703417e8446611c37cef56f38f3bbf2282795d Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 7 May 2024 10:39:14 +0800 Subject: [PATCH 3/3] rework the function --- src/components/Modal/BaseModal.tsx | 2 +- src/libs/actions/Modal.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Modal/BaseModal.tsx b/src/components/Modal/BaseModal.tsx index 89b7afce617d..b89d576d7274 100644 --- a/src/components/Modal/BaseModal.tsx +++ b/src/components/Modal/BaseModal.tsx @@ -75,7 +75,7 @@ function BaseModal( */ const hideModal = useCallback( (callHideCallback = true) => { - if (Modal.getModalVisibleCount() === 0) { + if (Modal.areAllModalsHidden()) { Modal.willAlertModalBecomeVisible(false); if (shouldSetModalVisibility) { Modal.setModalVisibility(false); diff --git a/src/libs/actions/Modal.ts b/src/libs/actions/Modal.ts index 5b907655cc3b..9cba7a359537 100644 --- a/src/libs/actions/Modal.ts +++ b/src/libs/actions/Modal.ts @@ -85,8 +85,8 @@ function willAlertModalBecomeVisible(isVisible: boolean, isPopover = false) { Onyx.merge(ONYXKEYS.MODAL, {willAlertModalBecomeVisible: isVisible, isPopover}); } -function getModalVisibleCount() { - return closeModals.length; +function areAllModalsHidden() { + return closeModals.length === 0; } -export {setCloseModal, close, onModalDidClose, setModalVisibility, willAlertModalBecomeVisible, setDisableDismissOnEscape, closeTop, getModalVisibleCount}; +export {setCloseModal, close, onModalDidClose, setModalVisibility, willAlertModalBecomeVisible, setDisableDismissOnEscape, closeTop, areAllModalsHidden};