I was developing a `Modal` component using the `
This surprised me, as accessibility guidelines for modals typically recommend trapping focus within the modal. This seemed incorrect to me.
Further research revealed that trapping focus within the `
Instead of reading the entire GitHub Issue discussion, here are some key points from notable contributors.
Scott O’Hara provides context on the focus-trapping advice history:
WCAG does not normatively require focus to be trapped within a dialog. The WCAG spec does not mention focus behavior requirements in a dialog.
The 2.4.3 focus order understanding document discusses limiting focus behavior within a dialog in the context of a scripted custom dialog, written before `inert` or `
The APG demonstrates ARIA usage. Without native HTML features like `
Both the APG modal dialog and the WCAG understanding document were written before the `inert` attribute or the `
Léonie Watson explains why it’s acceptable for a screen-reader user to move focus to the address bar:
In the page context, users can tab out of the bottom, navigate browser chrome, use keyboard commands to move to the address bar or open a menu, close the tab, etc. This provides choices for escaping the context.
It seems logical for the same options to be available in a dialog context.
Matatk shared the W3C’s Accessible Platform Architectures (APA) Working Group’s conclusion that the `
Several APA meetings concluded that the native dialog element’s current behavior should remain, allowing tabbing from the dialog to browser functionalities.
This benefits keyboard users, enabling actions like opening a new tab or changing browser settings. The dialog element provides a natural escape mechanism, such as moving to the address bar, in situations like kiosks where standard keyboard shortcuts are unavailable.
It appears we don’t need to worry about focus trapping when using the Dialog API’s `showModal` method correctly!
Hope this news makes component building easier for you. 😉



