-
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 attachment modal doesn't close when pressing search shortcut #27639
Fix attachment modal doesn't close when pressing search shortcut #27639
Conversation
} | ||
|
||
hideModal(true); |
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 think we should create a ref for hideModal
function too, but as it doesn't have any problem yet, I leave it as it is. Let me know if we should make it a ref too.
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 think ref is only needed for variables that are passed by value (not confirmed).
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.
Maybe, haven't tested it too
src/components/Modal/BaseModal.js
Outdated
if (!isVisible) { | ||
return; | ||
} | ||
Modal.willAlertModalBecomeVisible(false); | ||
Modal.setCloseModal(null); |
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 don't think this logic fits best as the cleanup logic. Can we done this using usePrevious instead?
useEffect(() => {
if (isVisible) {
Modal.willAlertModalBecomeVisible(true);
Modal.setCloseModal(onClose);
} else if (wasVisible && !isVisible) {
Modal.willAlertModalBecomeVisible(false);
Modal.setCloseModal(null);
}
}, [isVisible, wasVisible, onClose]);
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.
The cleanup func runs when isVisible
changes, so if isVisible
is updated to false
the cleanup func runs with isVisible
value is still true. I must admit it's harder to understand, so I updated it using your suggestion.
// To handle closing any modal already visible when this modal is mounted, i.e. PopoverReportActionContextMenu | ||
Modal.setCloseModal(isVisible ? onClose : null); | ||
}, [isVisible, onClose]); | ||
isVisibleRef.current = isVisible; |
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.
NAB. Is there a significant gain merging the two useEffects together? I think it's more readable to have the isVisibleRef useEffect separated
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.
Nope, just to reduce loc :). I think it's fine to put it here, we can even put it outside of useEffect
, but it will feels like out of place.
Reviewer Checklist
Screenshots/VideosWebweb.movDesktopdesktop.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/AndrewGable in version: 1.3.72-0 🚀
|
🚀 Deployed to production by https://github.com/thienlnam in version: 1.3.72-11 🚀
|
This caused regression: Repro step:
Screen.Recording.2023-10-12.at.6.35.41.PM.mov |
@0xmiroslav I think you marked the wrong PR. It is coming from this one instead. |
@bernhardoj I confirmed that reverting this PR fixes that bug |
@0xmiroslav I also confirmed reverting #28486 fix it.
Notice that it early returns when it is not visible, so That PR also caused this issue #29341. They should correct the |
// To handle closing any modal already visible when this modal is mounted, i.e. PopoverReportActionContextMenu | ||
Modal.setCloseModal(onClose); | ||
} else if (wasVisible && !isVisible) { | ||
Modal.willAlertModalBecomeVisible(false); |
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.
Hi @bernhardoj, we are thinking of moving this line, and the same line from the next useEffect
into the hideModal
function. Was there any specific reason not to do it in this PR? Just asking so that we won't break any edge case that I'm not aware of...
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 don't think there is any reason but just replicating the previous code.
Details
Pressing search shortcut while having attachment modal showing won't close the attachment modal.
Fixed Issues
$ #27359
PROPOSAL: #27359 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
Web/Desktop
Android/iOS/mWeb
Verify that we can still open any modal on the app
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)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)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
Web
Screen.Recording.2023-09-18.at.14.16.37.mov
Mobile Web - Chrome
Screen.Recording.2023-09-18.at.13.54.37.mov
Mobile Web - Safari
Screen.Recording.2023-09-18.at.13.54.14.mov
Desktop
Screen.Recording.2023-09-18.at.14.18.56.mov
iOS
Screen.Recording.2023-09-18.at.13.53.42.mov
Android
Screen.Recording.2023-09-18.at.14.09.45.mov