Skip to content
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

Merged
merged 2 commits into from
May 5, 2021
Merged

Fix escape key for modal closing #2695

merged 2 commits into from
May 5, 2021

Conversation

marcaaron
Copy link
Contributor

@marcaaron marcaaron commented May 5, 2021

Details

There are two situations where Escape key was not working

  1. The Popover component because react-native-modal is registering the Escape key press as a "back button press" and we are trying to close it twice (rather we toggle it so it just reopens again)
  2. When we moved the right hand panel modals to react-navigation we lost the ability to close via Escape. This should add that behavior back in at the ScreenWrapper level so that any screen wrapped in that component should be able to trigger a goBack() if the esc key is pressed

Fixed Issues

Fixes #1039

Tests

QA Steps

  1. Tap on the User avatar in the Sidebar
  2. Press Escape after the right panel opens
  3. Verify the right panel closes
  4. Repeat test with all similar right panel modals - New Chat, New Group, Search, Chat User Details etc
  5. Tap on the FAB
  6. Press Escape
  7. Verify the popover menus closes
  8. Click on an attachment in a chat to open the large modal
  9. Press Escape
  10. Verify the image view modal closes

Tested On

  • Web
  • Desktop

These platforms have no hardware keyboard so I did not bother to test them beyond ensuring no broken behaviors were introduced

  • Mobile Web - N/A
  • iOS - N/A
  • Android - N/A

Screenshots

Web

Mobile Web

Desktop

iOS

Android

@marcaaron marcaaron self-assigned this May 5, 2021
@marcaaron marcaaron marked this pull request as ready for review May 5, 2021 01:42
@marcaaron marcaaron requested a review from a team as a code owner May 5, 2021 01:42
@MelvinBot MelvinBot requested review from thienlnam and removed request for a team May 5, 2021 01:42
@@ -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);
Copy link
Contributor Author

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);
Copy link
Contributor Author

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.

@thienlnam thienlnam merged commit 53acb9c into main May 5, 2021
@thienlnam thienlnam deleted the marcaaron-escape branch May 5, 2021 21:18
@OSBotify
Copy link
Contributor

OSBotify commented May 5, 2021

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

OSBotify commented May 6, 2021

🚀 Deployed to staging in version: 1.0.38-1🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented May 8, 2021

🚀 Deployed to production in version: 1.0.39-5🚀

platform result
🤖 android 🤖 failure ❌
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Chat / The escape key should close open modals
3 participants