Skip to content

Commit

Permalink
Merge pull request Expensify#47622 from dominictb/fix/46388-modal-close
Browse files Browse the repository at this point in the history
fix: only dismiss the report attachment modal once
  • Loading branch information
thienlnam authored Aug 27, 2024
2 parents 5aaf6d7 + c38178b commit c9e53f6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/pages/home/report/ReportAttachments.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {StackScreenProps} from '@react-navigation/stack';
import React, {useCallback} from 'react';
import React, {useCallback, useEffect, useRef} from 'react';
import {useOnyx} from 'react-native-onyx';
import AttachmentModal from '@components/AttachmentModal';
import type {Attachment} from '@components/Attachments/types';
Expand All @@ -18,6 +18,14 @@ function ReportAttachments({route}: ReportAttachmentsProps) {
const accountID = route.params.accountID;
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID || -1}`);
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP);
const hasDismissedModalRef = useRef(false);

useEffect(
() => () => {
hasDismissedModalRef.current = false;
},
[],
);

// In native the imported images sources are of type number. Ref: https://reactnative.dev/docs/image#imagesource
const source = Number(route.params.source) || route.params.source;
Expand All @@ -39,7 +47,10 @@ function ReportAttachments({route}: ReportAttachmentsProps) {
report={report}
source={source}
onModalClose={() => {
Navigation.dismissModal();
if (!hasDismissedModalRef.current) {
Navigation.dismissModal();
hasDismissedModalRef.current = true;
}
// This enables Composer refocus when the attachments modal is closed by the browser navigation
ComposerFocusManager.setReadyToFocus();
}}
Expand Down

0 comments on commit c9e53f6

Please sign in to comment.