-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 cannot open search page by shortcut if delete receipt confirm modal is visible #33203
Changes from 2 commits
e5de1c7
d8d31f9
8055f3c
cc393f3
c2547ef
cf7c98d
e15c964
76c565a
d0f1991
bf23434
dd7a6f1
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,7 +1,7 @@ | ||||||||||
import Onyx from 'react-native-onyx'; | ||||||||||
import ONYXKEYS from '@src/ONYXKEYS'; | ||||||||||
|
||||||||||
const closeModals: Array<(isNavigating: boolean) => void> = []; | ||||||||||
const closeModals: Array<() => void> = []; | ||||||||||
|
||||||||||
let onModalClose: null | (() => void); | ||||||||||
|
||||||||||
|
@@ -21,24 +21,36 @@ function setCloseModal(onClose: () => void) { | |||||||||
}; | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Close topmost modal | ||||||||||
*/ | ||||||||||
function closeTop() { | ||||||||||
if (closeModals.length === 0) { | ||||||||||
return; | ||||||||||
} | ||||||||||
closeModals[closeModals.length - 1](); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Close modal in other parts of the app | ||||||||||
*/ | ||||||||||
function close(onModalCloseCallback: () => void, isNavigating = true) { | ||||||||||
function close(onModalCloseCallback: () => void) { | ||||||||||
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.
As you see, composer is briefly focused Screen.Recording.2024-01-21.at.8.13.56.PM.movthis logic was added here used in App/src/components/EmojiPicker/EmojiPicker.js Lines 85 to 88 in 52adf77
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. @aimane-chnaif done preserving the isNavigating parameter |
||||||||||
if (closeModals.length === 0) { | ||||||||||
onModalCloseCallback(); | ||||||||||
return; | ||||||||||
} | ||||||||||
onModalClose = onModalCloseCallback; | ||||||||||
[...closeModals].reverse().forEach((onClose) => { | ||||||||||
onClose(isNavigating); | ||||||||||
}); | ||||||||||
closeTop(); | ||||||||||
} | ||||||||||
|
||||||||||
function onModalDidClose() { | ||||||||||
if (!onModalClose) { | ||||||||||
return; | ||||||||||
} | ||||||||||
if (closeModals.length) { | ||||||||||
closeTop(); | ||||||||||
return; | ||||||||||
} | ||||||||||
onModalClose(); | ||||||||||
onModalClose = null; | ||||||||||
} | ||||||||||
|
@@ -58,4 +70,4 @@ function willAlertModalBecomeVisible(isVisible: boolean) { | |||||||||
Onyx.merge(ONYXKEYS.MODAL, {willAlertModalBecomeVisible: isVisible}); | ||||||||||
} | ||||||||||
|
||||||||||
export {setCloseModal, close, onModalDidClose, setModalVisibility, willAlertModalBecomeVisible}; | ||||||||||
export {setCloseModal, close, onModalDidClose, setModalVisibility, willAlertModalBecomeVisible, closeTop}; |
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.
This is needed to prevent react native modal to show blue border box (because of focused state) of threedots button on modal hide when user close modal by pressing esc:
Video:
blue-border-d.mp4
This is because of trap focus of react native modal.
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.
I am not able to reproduce. Btw, if you reproduced, can you confirm also reproducible on staging/production?
If so, no need to fix here.
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.
@aimane-chnaif Because I am using
onBackButtonPress={Modal.closeTop}
in BaseModal.tsx to fix an issue about: When user press three dots menu on attachment modal then pressesc
the attachment modal is closed. The current behavior in staging:Pressing esc on three dots menu in attachment modal:
esc-on-staging-d.mp4
After using
onBackButtonPress={Modal.closeTop}
:blue border appears:
blue-border-current-branch-d.mp4