-
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: Attachments reopen on multiple 'esc' click and hang on browser's navigation back #31524
fix: Attachments reopen on multiple 'esc' click and hang on browser's navigation back #31524
Conversation
Move setReadyToFocus fully to hideModal
@abdulrahuman5196 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] |
onModalHide={() => { | ||
Navigation.dismissModal(); | ||
// 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.
@abdulrahuman5196 I decided to go with my alternative solution for the Composer refocus on navigation because removing the !fullscreen
check in hideModal
would cause a regression on the Composer refocus after closing the Emoji picker.
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.
Do we need this change? What does change bring in? @paultsimura
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 focuses the composer when we navigate back by clicking the browser's "Back" button. Otherwise, ComposerFocusManager.setReadyToFocus()
is called within BaseModal
in 2 places:
App/src/components/Modal/BaseModal.tsx
Lines 115 to 117 in d521dd6
const handleDismissModal = () => { | |
ComposerFocusManager.setReadyToFocus(); | |
}; |
App/src/components/Modal/BaseModal.tsx
Lines 66 to 68 in d521dd6
if (!fullscreen) { | |
ComposerFocusManager.setReadyToFocus(); | |
} |
The AttachmentsModal
is fullscreen, so the hideModal
does not call the ComposerFocusManager.setReadyToFocus()
.
Also, the Modal's onDismiss
is not called when we are navigating – it's the RN limitation. The component just gets destroyed without calling the onDismiss
.
Therefore, the ComposerFocusManager.setReadyToFocus()
is not called in these two places in the BaseModal
, so we need to call it explicitly.
@abdulrahuman5196 all yours, thanks |
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.
@paultsimura Could you provide information on the requested questions?
onModalHide={() => { | ||
Navigation.dismissModal(); | ||
// 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.
Do we need this change? What does change bring in? @paultsimura
@@ -56,6 +56,7 @@ function BaseModal( | |||
*/ | |||
const hideModal = useCallback( | |||
(callHideCallback = true) => { | |||
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.
Same here. What does this change provide?
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.
Here I just moved Modal.willAlertModalBecomeVisible(false)
from 2 useEffect
hooks into hideModal
.
This removes the race condition when double-clicking the esc
button, as the hideModal
is eventually called after each of those hooks, therefore Modal.willAlertModalBecomeVisible(false)
will be called when the modal gets hidden. Without this change, the composer won't get focused when double-clicking esc
.
I asked the original author here - there was no specific reason to put this call inside the hooks instead of the hideModal
: #27639 (comment)
Thanks @abdulrahuman5196, replied. |
# Conflicts: # src/components/Modal/BaseModal.tsx
@abdulrahuman5196 a friendly bump 🙏 |
Checking again now |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2023-11-23.at.9.21.08.PM.mp4Android: mWeb ChromeScreen.Recording.2023-11-23.at.9.22.51.PM.mp4iOS: NativeScreen.Recording.2023-11-23.at.8.48.18.PM.mp4iOS: mWeb SafariScreen.Recording.2023-11-23.at.9.12.42.PM.mp4MacOS: Chrome / SafariScreen.Recording.2023-11-23.at.7.26.42.PM.mp4MacOS: DesktopScreen.Recording.2023-11-23.at.7.35.32.PM.mp4 |
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.
Changes looks good and works well. Reviewers checklist is also complete.
All yours. @hayata-suenaga
🎀 👀 🎀
C+ Reviewed
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 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/hayata-suenaga in version: 1.4.4-0 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 1.4.4-3 🚀
|
Details
This fixes 2 issues:
Use focus with delay on modal close;
Move setReadyToFocus fully to hideModal
Fixed Issues
$ #27237
PROPOSAL: #27237 (comment)
Tests
Same as QA
Offline tests
Same as QA
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-compressed.mp4
Android: mWeb Chrome
chrome-compressed.mp4
iOS: Native
ios.mp4
iOS: mWeb Safari
safari.mp4
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4