Issue
When the dialog is first opened, the focus is not set in a place that makes it easy to access the content in the rest of the dialog, and it's possible to navigate components hidden behind the dialog.
Resources
https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/
Developer notes
While aria-modal="true" removes requirement of putting aria-hidden on background content, as the aria-modal informs assistive technologies that content outside a dialog is inert, it's the safer way currently to have both attributes in use on the dialog and the background content elements.
The escaping of dialogs by pressing ⎋ (ESC) has already been part since the original Dialog implementation.
Best practices identified
- Add aria-modal="true" to the role="dialog" element.
- Focus on initial dialog open should work in a predictable way.
- Users should not be able to interact with content behind the dialog when open.
- Remain aria-hidden="true" for its wider support than only aria-modal on background elements incl script
- Add inert as future-facing attribute for non-interactable background elements as well
The user should always have a way to exit the dialog using keyboard navigation.In initial implementation