-
-
Notifications
You must be signed in to change notification settings - Fork 32.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
[Modal] Ignore event.defaultPrevented #14991
[Modal] Ignore event.defaultPrevented #14991
Conversation
2d7d029
to
dbd7e43
Compare
dbd7e43
to
b0e71d5
Compare
Details of bundle changes.Comparing: d1a7d76...b0e71d5
|
Like the change but it's probably a bit controversial. Is there some spec that we can point to that defines default behavior of events? |
I guess https://www.w3.org/TR/uievents/#event-type-keydown will do. No mention about default behavior of the Escape key so Well spec doesn't help here really:
Essentially means default is what we define default. The default behavior of pressing Escape on an element is not to close a modal because elements are not in a modal by default. It's a bit circular but should suffice. |
Follow up on #13470 (comment). The change was encouraged by @stevemao.
Breaking change
The new logic closes the Modal even if
event.preventDefault()
is called on the key down escape event.event.preventDefault()
is meant to stop default behaviors like clicking a checkbox to check it, hitting a button to submit a form, and hitting left arrow to move the cursor in a text input etc. Only special HTML elements have these default behaviors. People should useevent.stopPropagation()
if they don't want to trigger aonClose
event on the modal.