humaan / Modaal

An accessible dialog window library for all humans.
http://humaan.com/modaal/
MIT License
2.72k stars 183 forks source link

Focus management (focus trap) #121

Open simobari opened 5 years ago

simobari commented 5 years ago

Hello there,

wondering why you haven't implemented the focus trap inside the dialog as advised here:

https://www.w3.org/TR/wai-aria-practices-1.1/examples/dialog-modal/dialog.html

I think it's fundamental to define the Modal accessible.

Thanks

dotherightthing commented 3 years ago

https://github.com/humaan/Modaal/blob/68a5abc0ab74291becac88e758462ec39539697c/source/js/modaal.js#L209-L259 watch_events() appears to handle this already. However when I test this, the focus is still 'lost' for a couple of tab presses. One of these is a top-of-page skip link. I'm unsure if this is a problem with our codebase or not.