-
Notifications
You must be signed in to change notification settings - Fork 3k
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: only dismiss the report attachment modal once #47622
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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} from 'react'; | ||||||
import {useOnyx} from 'react-native-onyx'; | ||||||
import AttachmentModal from '@components/AttachmentModal'; | ||||||
import type {Attachment} from '@components/Attachments/types'; | ||||||
|
@@ -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 = React.useRef(false); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Was there any reason why you didn't import the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @allgandalf sorry, maybe the code completion cause this. Fixed in the latest commit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. haha, no worries, happens on best of our days 😄 |
||||||
|
||||||
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; | ||||||
|
@@ -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(); | ||||||
}} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.