-
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
Focus compose field when modal dismissed #1780
Focus compose field when modal dismissed #1780
Conversation
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 to adjust the onModalHide()
callback in the render method below? If those aren't firing at all now, then there is maybe a little more we should do when unmounting the component.
@tgolen yeah I believe The only things happening here other than
So I think we're good to go - but obviously I defer to you :D |
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
OK, thanks. Can |
@tgolen as per our discussion, I've moved the repetitive code into a new function I also added the updates in the OP so it remains accurate |
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.
Nice!
Details
Re-implemented compose field being focused when a page-level modal gets dismissed (this broke due to a small regression that was introduced by the recent React-navigation overhaul).
Before the React-Navigation upgrade, closing a page-modal (like /search) would trigger
BaseModal
'sonModalHide
callback, which is where we handled a few important things (mainly unsubscribing from keyboard events and setting modal visibility).After the React-navigation overhaul, when a user navigates away from a page with a modal,
BaseModal
gets taken out of the DOM before it has time to trigger itsonModalHide
callback.To fix, I've added a new function
hideModalAndRemoveEventListeners
which contains the functions to hide the modal and unregister key event listeners. This function is now called incomponentWillUnmount
(for page-modals that unmount immediately upon navigation) and inonModalHide
(for FAB, which isn't unmounted after its modal hides).Other notes can be found here: https://github.com/Expensify/Expensify/issues/154180#issuecomment-799676117
Note: Original PR which focused the compose field when closing modals (cc @tgolen): #1699
Fixed Issues
Fixes https://github.com/Expensify/Expensify/issues/154180Tests
Tested On
iOS(n/a because the field does not get focus by design)Android(n/a because the field does not get focus by design)Screenshots
Web
Not really any screenshots necessary
Mobile Web
Not really any screenshots necessary
Desktop
Not really any screenshots necessary
iOS
Not really any screenshots necessary
Android
Not really any screenshots necessary