This repository has been archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
fix(Popup|Dialog): ESC should close opened Popup/Dialog if focus is lost and moved to body #1807
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sophieH29
added
🧰 bug
Something isn't working
🚀 ready for review
accessibility
All the Accessibility tasks and bugs should be tagged with this.
labels
Aug 16, 2019
sophieH29
requested review from
dvdzkwsk,
kuzhelov,
layershifter,
levithomason,
miroslavstastny and
mnajdova
as code owners
August 16, 2019 09:20
Codecov Report
@@ Coverage Diff @@
## master #1807 +/- ##
==========================================
- Coverage 69.77% 69.74% -0.04%
==========================================
Files 875 875
Lines 7508 7519 +11
Branches 2182 2186 +4
==========================================
+ Hits 5239 5244 +5
- Misses 2261 2267 +6
Partials 8 8
Continue to review full report at Codecov.
|
Can we add a test? |
layershifter
changed the title
fix: ESC should close opened Popup/Dialog if focus is lost and moved to body
fix(Popup|Dialog): ESC should close opened Popup/Dialog if focus is lost and moved to body
Aug 16, 2019
@@ -203,6 +204,20 @@ class Dialog extends AutoControlledComponent<WithAsProp<DialogProps>, DialogStat | |||
} | |||
} | |||
|
|||
handleDocumentKeydown = (getRefs: Function) => e => { |
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.
Suggested change
handleDocumentKeydown = (getRefs: Function) => e => { | |
handleDocumentKeydown = (getRefs: Function) => (e: KeyboardEvent) => { |
More type safety 🏋
lastOverlayRef && lastOverlayRef.current === this.overlayRef.current | ||
|
||
const keyCode = keyboardKey.getCode(e) | ||
if (keyCode === keyboardKey.Escape && isLastOpenedDialog && this.state.open) { |
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.
Suggested change
if (keyCode === keyboardKey.Escape && isLastOpenedDialog && this.state.open) { | |
if (keyboardKey.getCode(e) === keyboardKey.Escape && isLastOpenedDialog) { |
You don't need this.state.open
as this event listener will be mounted only when Dialog
is open
:
<Portal open={open} /* here we are */>
<EventListener type="keydown" />
</Portal>
layershifter
approved these changes
Aug 19, 2019
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
accessibility
All the Accessibility tasks and bugs should be tagged with this.
🧰 bug
Something isn't working
🚀 ready for review
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1709