Repository navigation
fix(a11y): name every dialog after its title - #377
Merged
Merged
Conversation
Dialogs had role="dialog" (Zarestia-Dev#373) but no accessible name, so screen readers announced only "dialog" (Zarestia-Dev#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 was referenced Nov 25, 2026
Hakanbaban53
approved these changes
Nov 25, 2026
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, as agreed there.
What
Since #373 dialogs have
role="dialog", but no accessible name, so a screen reader announces just "dialog" when one opens.The modals put their title in
<header><p>…</p></header>rather than usingmat-dialog-title(which would also apply Material's title styles). So instead of editing every modal, a small root service,DialogLabelsService(started from the app initializer), does whatmat-dialog-titledoes: when a dialog opens, it gives the header's title an id and adds it to the container'saria-labelledbythrough the same_addAriaLabelledBycall the directive uses.h1/h2(its title).ariaLabel: "Preferences"(the existing title string).ariaLabelkeeps it; one with no title is left alone rather than guessed.No visual change and no new strings.
Tests
dialog-labels.service.spec.ts: a dialog is named by its header title (not its close button or body), a dialog without a header by its heading, anariaLabelis kept, and an untitled dialog gets no label. The first fails without the service.ng buildpass.