Fix: Only the delete confirmation modal should close when pressing ESC button#31256
Fix: Only the delete confirmation modal should close when pressing ESC button#31256MariaHCD merged 8 commits intoExpensify:mainfrom
Conversation
|
@hoangzinh Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
| type={modalType} | ||
| onSubmit={submitAndClose} | ||
| onClose={closeModal} | ||
| onClose={isOverlayModalVisible ? null : closeModal} |
There was a problem hiding this comment.
Is it better if we do
function handleCloseModal() {
if (isOverlayModalVisible) return;
closeModal();
}
...
onClose={handleCloseModal}There was a problem hiding this comment.
cc @dukenv0307 just in case you missed this message
There was a problem hiding this comment.
@hoangzinh Sorry for the delay, I don't know how I miss the notification.
Your suggestion seems valid but when I tried to apply it, the weird part is that the Confirm modal didn't close 😵💫
Taking a closer look now.
There was a problem hiding this comment.
@hoangzinh
Actually, if we assign a function to onClose, the onClose function in Modal in the outside
App/src/components/AttachmentModal.js
Line 412 in 47c7819
On the other hand, if onClose in the outter Modal is assigned to null, onClose function in Confirm modal will be triggered, this will trigger
App/src/components/AttachmentModal.js
Line 493 in 47c7819
onCancel, then onCalcel set isAttachmentInvalid to false then close Confirm modal
So, I think it is better to keep the current code change.
Let me know if any concerns.
There was a problem hiding this comment.
if onClose in the outter Modal is assigned to null, onClose function in Confirm modal will be triggered
Could you elaborate more on this one? I still do not understand what is different between them.
There was a problem hiding this comment.
Interesting! It looks like if we pass a null value to onBackButtonPress of AttachmentModal, then the onBackButtonPress will be triggered for Confirm modal. Am I correct? If yes, because this one is not trivial, do you think we can pass an additional prop to Modal, then we wrap this magic inside Modal implementation. In other places, we can just pass a prop like isOverlayed, then everything will be handled inside Modal
There was a problem hiding this comment.
I want to double-confirm here:
You want to update the code here
App/src/components/Modal/BaseModal.tsx
Line 174 in 72e73ae
to something like:
onBackButtonPress={isOverlayModalVisible ? null : closeModal}This will fail since onBackButtonPress of ReactNativeModal expects (() => void) | undefined and the code works for null only, not undefined.
I believe the current code is pretty straightforward to fix the problem without introducing any potential bug like adding additional logic to the Modal component
There was a problem hiding this comment.
Interesting! Hmm, you're right, but with current implementation of this PR, if we want to migrate this AttachmentModal component to typescript, what would we do with onClose={isOverlayModalVisible ? null : closeModal}.
There was a problem hiding this comment.
I found a related upstream issue. It looks like we have to handle it in application level react-native-modal/react-native-modal#623 (comment).
Hmm. How about if isOverlayModalVisible is true, we will call closeConfirmModal, otherwise we will call closeModal.
There was a problem hiding this comment.
That's worked. Please re-check the PR and let me know if any concerns
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2023-11-23.at.21.26.38.-.android.movAndroid: mWeb ChromeScreen.Recording.2023-11-23.at.20.14.14.-.android.chrome.moviOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2023-11-23.at.19.57.32.-.web.movMacOS: DesktopScreen.Recording.2023-11-23.at.19.59.20.-.desktop.mov |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/MariaHCD in version: 1.4.4-0 🚀
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.4.4-3 🚀
|
Details
Only the delete confirmation modal should close when pressing ESC button
Fixed Issues
$ #30045
PROPOSAL: #30045 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
android.mov
Android: mWeb Chrome
chrome.mov
iOS: Native
ios-resize.mov
iOS: mWeb Safari
safari-resize.mov
MacOS: Chrome / Safari
web-resize.mov
MacOS: Desktop
desktop.mov