Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user is navigated to IOU report when dismissing receipt modal with ESC key #41472

Merged
Show file tree
Hide file tree
Changes from 2 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
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.getModalVisibleCount() === 0) {
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 getModalVisibleCount() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose we call this something like allModalsHidden and make it return closeModals.length === 0, since we don't care about the number of visible modals, all we care about is whether there's at least one modal visible

Also please add a comment explaining what this function does

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, but I prefer to not give it a comment since the name itself is already self-explanatory.

return closeModals.length;
}

export {setCloseModal, close, onModalDidClose, setModalVisibility, willAlertModalBecomeVisible, setDisableDismissOnEscape, closeTop, getModalVisibleCount};
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
Loading