-
Notifications
You must be signed in to change notification settings - Fork 415
Description
Under keyboard interaction for a modal dialog, it says the behavior for Tab should be:
If focus is on the last tabbable element inside the dialog, moves focus to the first tabbable element inside the dialog.
For Shift+Tab, it recommends the reverse:
If focus is on the first tabbable element inside the dialog, moves focus to the last tabbable element inside the dialog.
The native <dialog>
element disagrees with the spec in this behavior. Instead of cycling through elements inside the modal dialog, Tab and Shift+Tab cause focus to eventually escape to the browser chrome itself (URL bar, etc.). In other words, when you reach the end of the list of tabbable elements, the "next" or "previous" tabbable element is inside the browser chrome, not at the opposite end of the modal dialog. This occurs in both Chrome 87 and Firefox 85 (with the flag dom.dialog_element.enabled
).
The <dialog>
spec only says that, when showModal()
is called on the dialog, every other node in the document should become inert
. So when focus escapes to the browser chrome, it's effectively just a product of the fact that this is how a normal web page works even without a dialog. On example.com you can press Tab and Shift+Tab to eventually arrive at the browser chrome.
Because of this, it seems reasonable to me to modify the WAI-ARIA Authoring Practices to allow for Tab and Shift+Tab to escape to the browser chrome. I would propose making it optional – focus can either cycle through the tabbable elements inside the modal dialog, or it can eventually escape to the browser chrome. (In either case, tabbable elements in the document but outside the modal dialog would not be reachable.)
There is actually a precedent here with window.alert and window.prompt. As I understand it, these used to be browser-modal (i.e. would block the entire browser), but are now content-modal (only blocking the relevant browser tab) in modern version of Chrome, Firefox, and Safari. (See relevant Firefox bugs.) This means that you can Tab through the focusable elements inside the modal, and eventually wind up in the browser chrome. So arguably, the WAI-ARIA guidelines for a modal dialog should be the same.
It's also worth mentioning that using the native <dialog>
is apparently the only way to allow for keyboard interaction with closed shadow roots and user agent shadow roots (such as <video controls>
and <audio controls>
) when inside a modal dialog. And this behavior cannot be combined with the "cycling" Tab behavior – it's not possible for web authors to control focus change inside of closed/UA shadow roots. So if <dialog>
is considered inaccessible per WAI-ARIA, that would leave web authors with no good options. (I'm disregarding other accessibility problems with <dialog>
, which at least seem solvable on the part of web authors or screen reader vendors.)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status