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

Fixing Dialog Escape keypress behavior #831

Merged
merged 2 commits into from
Sep 10, 2020

Conversation

aleksfront
Copy link
Contributor

Allowing to close Dialog only (not along with opened Drawer) after hitting Esc key. Made by changed keypress target - document.body is located 'lower' in event bubbling stairs so it will fire event earlier than Drawer.

esc closes dialog

Fixes #757

Signed-off-by: Alex Andreev alex.andreev.email@gmail.com

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
@aleksfront aleksfront requested a review from a team September 9, 2020 08:45
@@ -92,15 +92,15 @@ export class Dialog extends React.PureComponent<DialogProps, DialogState> {
this.props.onOpen();
if (!this.props.pinned) {
if (this.elem) this.elem.addEventListener('click', this.onClickOutside);
window.addEventListener('keydown', this.onEscapeKey);
document.body.addEventListener('keydown', this.onEscapeKey);
Copy link
Member

@ixrock ixrock Sep 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comment (to the code) why document.body is used and how it's related to Drawer's event(s).

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
@aleksfront aleksfront merged commit e11cbc1 into master Sep 10, 2020
@aleksfront aleksfront deleted the fix-esc-closes-dialog-and-drawer branch September 10, 2020 06:31
This was referenced Sep 11, 2020
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.

Esc closes too many windows at once
3 participants