Repository navigation
fix(a11y): keep Material's dialog defaults - #373
Merged
Hakanbaban53 merged 1 commit intoNov 25, 2026
Merged
Conversation
MAT_DIALOG_DEFAULT_OPTIONS replaces new MatDialogConfig() instead of
adding to it, so providing { closeOnNavigation: false } dropped
role="dialog", autoFocus and restoreFocus from every dialog. Dialogs
opened without a role, focus stayed on the button behind them, Tab moved
through the page underneath, and closing did not return focus. Start the
defaults from new MatDialogConfig() (Zarestia-Dev#354).
Hakanbaban53
approved these changes
Nov 25, 2026
This was referenced Nov 25, 2026
Hakanbaban53
pushed a commit
that referenced
this pull request
Nov 25, 2026
Dialogs had role="dialog" (#373) but no accessible name, so screen readers announced only "dialog" (#354). Modals put their title in <header><p>, not mat-dialog-title (which would also restyle it), so DialogLabelsService links that title to the dialog the way the directive does, through the container's aria-labelledby queue. A dialog without a header (the confirm dialog) is named by its first h1 or h2. Preferences shows its tabs instead of a title on wide windows, so it opens with its title as aria-label.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #354.
What
app.config.tsprovidesMAT_DIALOG_DEFAULT_OPTIONSas{ closeOnNavigation: false }. Material uses that object in place ofnew MatDialogConfig(), not on top of it ({ ...(this._defaultOptions || new MatDialogConfig()), ...config }), so every dialog lostrole="dialog",autoFocus: 'first-tabbable'andrestoreFocus: true.In the headless UI on master, opening Quick Remote or Preferences (by mouse or keyboard):
The defaults now start from
new MatDialogConfig()and keepcloseOnNavigation: false. Nothing else changes visibly: the backdrop already came from the CDK's own defaults, Material sets no default size, and every app dialog sets its own size anddisableClose. The first button inside a dialog now gets focus, so its focus highlight shows when it was opened by keyboard.Tests
app.config.spec.ts: the defaults keeprole,autoFocusandrestoreFocus, and a dialog opened with them hasrole="dialog", takes focus, and gives it back to the trigger when it closes. With the old value, both tests fail.role="dialog", take focus, keep Tab inside for 25 presses, and return focus to the menu button on close.ng buildpass.Follow-up: the dialogs still have no accessible name (no
aria-labelledbyon their title); that needs a per-dialog change, so it's not in this PR.