Google Chrome closes <dialog>
elements when Esc is pressed. Seems to be reacting to keydown.
Firefox does not. This is the expected behavior, as closing on any key press is easy to implement.
How to make Google Chrome leave dialogs open on Esc?
Please see fiddle https://jsfiddle.net/zeqo7kaf/1/
I have implemented window
's, document
's, body
's, dialog
's key events (up, down and pressed) to prevent propagation, however it seems to me that this is above dom events.
(in order to see dialogs in Firefox, go to about:config
and set property dom.dialog_element.enabled
to true
).
cancel
event documentation is now underHTMLElement
, which is a bit unfortunate because the page forHTMLDialogElement
does not have a good example for it, and only lists theclose
event that seems to fire only after the dialog is closed. Also in Chrome, pressing Esc twice still seems to close it even after preventing... In Firefox it works as expected – Plumose