You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P1][a11y] Dialogs don't trap focus, don't take focus when opened, and mostly ignore Escape #701
Open a dialog and focus stays wherever it was — behind the dialog. Tab walks
through the page underneath, which is still fully focusable, while the dialog
sits on top. There is no way to reach the dialog's own controls except with
the mouse, and in 13 of 17 the only reliable way out is clicking the backdrop.
DESIGN_REQUIREMENTS.md §1.3 commits to the opposite:
Keyboard-Driven — Power users live on the keyboard. Every action is
accessible via keyboard shortcut. Mouse is supported but never required.
For dialogs, the mouse is currently required.
Without role="dialog"/aria-modal, a screen reader is not told a modal
opened at all, and keeps reading the page behind it.
Fix
One shared <Modal> wrapper that owns the whole contract, rather than 17
partial implementations:
role="dialog" + aria-modal="true" + aria-labelledby pointing at the title
move focus to the dialog (or its first field) on open
trap Tab and Shift+Tab within it
Escape closes
restore focus to the invoking element on close
Mechanical to apply once it exists: the dialogs already share a shape
(backdrop div, panel div, header with a close button), so most become a
wrapper swap.
Worth adding
A shared test helper asserting the contract, run against every dialog. The
count above came from grep, which is exactly the kind of thing a test should
be asserting instead.
Activity
feat(a11y): give dialogs a focus contract, and put seven of them on it (