-
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 escape key for modal closing #2695
Conversation
@@ -79,7 +79,10 @@ class AttachmentModal extends PureComponent { | |||
return; | |||
} | |||
|
|||
this.props.onConfirm(this.state.file); | |||
if (this.props.onConfirm) { | |||
this.props.onConfirm(this.state.file); |
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 change is unrelated. I just noticed that if we press Enter on a regular attachment modal it throws a TypeError
so I fixed that up.
*/ | ||
subscribe(key, callback, modifiers = 'shift', captureOnInputs = false) { | ||
const keyCode = this.getKeyCode(key); | ||
if (events[keyCode] === undefined) { | ||
events[keyCode] = []; | ||
} | ||
events[keyCode].push({callback, modifiers: _.isArray(modifiers) ? modifiers : [modifiers], captureOnInputs}); | ||
return () => this.unsubscribe(key); |
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 is kind of extra. Probably didn't need to do it, but I like this pattern for cleaning up subscriptions.
✋ 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 in version: 1.0.38-1🚀
|
🚀 Deployed to production in version: 1.0.39-5🚀
|
Details
There are two situations where
Escape
key was not workingPopover
component becausereact-native-modal
is registering theEscape
key press as a "back button press" and we are trying to close it twice (rather we toggle it so it just reopens again)react-navigation
we lost the ability to close viaEscape
. This should add that behavior back in at theScreenWrapper
level so that any screen wrapped in that component should be able to trigger agoBack()
if theesc
key is pressedFixed Issues
Fixes #1039
Tests
QA Steps
Escape
after the right panel opensEscape
Escape
Tested On
These platforms have no hardware keyboard so I did not bother to test them beyond ensuring no broken behaviors were introduced
Screenshots
Web
Mobile Web
Desktop
iOS
Android