Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(material/core): mat-optgroup labels are read twice during screen-reader page navigation #21858

Merged
merged 1 commit into from Feb 18, 2021

Conversation

axverma
Copy link
Contributor

@axverma axverma commented Feb 10, 2021

Fixed by adding aria-hidden="true" to the elements, so that while screenreaders will still announce the label text for the group (due to the aria-labelledby property on mat-optgroup), they will skip over the actual label element. Additionally, changed the label to a span to make it clear that the text is visual only and not carrying any special semantic meaning for the a11y tree.

Fixes #21857

@axverma axverma requested a review from crisbeto as a code owner Feb 10, 2021
@google-cla google-cla bot added the cla: yes label Feb 10, 2021
@axverma axverma changed the title fix(material/core): mat-optgroup labels can be are read twice during screen-reader page navigation fix(material/core): mat-optgroup labels are read twice during screen-reader page navigation Feb 10, 2021
Copy link
Member

@crisbeto crisbeto left a comment

Also spent some time testing it with a screen reader and didn't notice any issues.

@@ -1,2 +1,2 @@
<label class="mat-optgroup-label" [id]="_labelId">{{ label }} <ng-content></ng-content></label>
<span class="mat-optgroup-label" aria-hidden="true" [id]="_labelId">{{ label }} <ng-content></ng-content></span>
Copy link
Member

@crisbeto crisbeto Feb 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same fix will have to be applied to the MDC-based option group in src/material-experimental/mdc-core/option/optgroup.html.

Copy link
Contributor Author

@axverma axverma Feb 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the changes to src/material-experimental/mdc-core/option/optgroup.html.

I described the a11y issues I saw in #21847 (with ChromeVox and with VoiceOver + Chrome). I believe removing the group labels from the a11y tree would stop the double-reading in these cases without impacting browsers that do not have this issue. I could provide some screen recordings if that would help.

…reader page navigation.

Fixed by adding aria-hidden="true" to the <label> elements.
While screenreaders will still announce the label text for the group they will skip over the actual label element.
Additionally, changed the <label> to a <span> to make it clear that the text is visual only.
Copy link
Member

@crisbeto crisbeto left a comment

LGTM

@crisbeto crisbeto added a11y G merge ready P3 target: patch labels Feb 11, 2021
@andrewseguin andrewseguin merged commit ca37709 into angular:master Feb 18, 2021
16 checks passed
andrewseguin pushed a commit that referenced this issue Feb 18, 2021
…reader page navigation. (#21858)

Fixed by adding aria-hidden="true" to the <label> elements.
While screenreaders will still announce the label text for the group they will skip over the actual label element.
Additionally, changed the <label> to a <span> to make it clear that the text is visual only.

Co-authored-by: Akshay Verma <vakshay@google.com>
(cherry picked from commit ca37709)
@axverma axverma deleted the optgroup-sr branch Feb 18, 2021
@angular-automatic-lock-bot
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Mar 21, 2021

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a11y cla: yes G merge ready P3 target: patch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants