No events emitted when closing via Escape

#4 · open · 1 comments

View on GitHub ↗

philipp-spiess

When closing a modal via the <kbd>Esc</kbd> key, no `toggle` or `beforetoggle` events are created: https://jsfiddle.net/7z895a2L/ I _think_ we want something like this (at least I can't think of a better way so far): ```js document.addEventListener( "keydown", (event) => { if (event.key !== 'Escape') return; if (event.defaultPrevented) return; const dialog = event.target.closest("dialog") if (dialog instanceof HTMLDialogElement) { dialogCloseEvents(dialog) } } ) ``` Been playing around with it in this jsfiddle: https://jsfiddle.net/7z895a2L/3/

Comments

keithamus

This looks like a good start. PRs welcome!