Modaal icon indicating copy to clipboard operation
Modaal copied to clipboard

Using the <dialog> tag

Open craigfrancis opened this issue 9 years ago • 2 comments
trafficstars

You could look at the HTML5 dialog tag, as it will give much better symantics for assistive devices (or simply the browser) to use.

For example, when the dialog is "open" and "modal", supporting browsers will limit the focusable controls to those elements within the dialog (e.g. tabbing between elements won't focus anything else on the page, so you don't need to do anything in JS to fix that).

https://github.com/GoogleChrome/dialog-polyfill

https://developer.mozilla.org/en/docs/Web/HTML/Element/dialog

craigfrancis avatar Oct 17 '16 08:10 craigfrancis

Thanks for sharing @craigfrancis when we have a bit more time free we'll do some reading on this spec. Ideally we'd prefer not to have to load a polyfill with the library, but it's definitely worth us doing some reading.

danhumaan avatar Dec 12 '16 00:12 danhumaan

Just for reference, you are kind of doing all the work of the pollyfill anyway, so you shouldn't need to include any extra JS.

Hopefully (and this is from someone who hasn't really looked in detail at your code), you will be able to change:

<div class="modaal-wrapper...

To

<dialog class="modaal-wrapper...

Then update the appropriate methods to either call the native showModal()/close() methods, or call your own.

This would help provide some semantics to the document, and help with tab focus (as browsers that support these will be able to do a much cleaner job than looking at e.keyCode == 9).

One thing that might be odd is handling the ::backdrop for styling.

:-)

craigfrancis avatar Dec 12 '16 07:12 craigfrancis