-
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: Only the delete confirmation modal should close when pressing ESC button #31256
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] |
src/components/AttachmentModal.js
Outdated
@@ -398,7 +400,7 @@ function AttachmentModal(props) { | |||
<Modal | |||
type={modalType} | |||
onSubmit={submitAndClose} | |||
onClose={closeModal} | |||
onClose={isOverlayModalVisible ? null : closeModal} |
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.
Is it better if we do
function handleCloseModal() {
if (isOverlayModalVisible) return;
closeModal();
}
...
onClose={handleCloseModal}
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.
cc @dukenv0307 just in case you missed this message
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.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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
onClose={closeModal} |
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={closeConfirmModal} |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to double-confirm here:
You want to update the code here
App/src/components/Modal/BaseModal.tsx
Line 174 in 72e73ae
onBackButtonPress={onClose} |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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.
LGTM
✋ 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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.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