-
Notifications
You must be signed in to change notification settings - Fork 843
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
Properly cancel keydown events after handling #344
Conversation
CHANGELOG.md
Outdated
@@ -2,6 +2,10 @@ | |||
|
|||
No public interface changes since `0.0.15`. | |||
|
|||
**Bug fixes** | |||
|
|||
- Stop propagation and prevent default when closing components. [(#344)](https://github.com/elastic/eui/pull/344) |
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.
Can we flesh this out?
- Stop propagation and prevent default when closing components. Otherwise the same Escape keypress could close the parent component(s) as well as the one you intend to close. [(#344)](https://github.com/elastic/eui/pull/344)
@timroes Did you look in popover too? I think ESC is used to close that component as well. |
@cjcenizal you were right. I searched the whole repository, but for |
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.
LGTM! Did you test this and verify that it solved the original problem?
@cjcenizal yeah it fixes the issue. |
Is this ready to be merged @timroes ? |
Yeah, just waiting for the second review, or can we also merge with one review in EUI? |
I think one is OK, it's up to you. |
Whenever we handle a keydown event, we should properly prevent it's default behavior and also stop propagation to parent nodes. Otherwise the same Escape keypress could close multiple components.
I have the case where I have an
EuiCodeBlock
in anEuiFlyout
. If you now open the code block fullscreen and press Escape both components will close, because theEuiCodeBlock
doesn't stop propagation when handling its close event.That same will be true for any of these components if you place them in something else, that tries to handle the same keypress. In general: if we handle a keyevent we should prevent it's default behavior and stop its propagation.