Skip to content

Commit 398ce36

Browse files
Akshay Vermaaxverma
authored andcommitted
fix(material/core): mat-optgroup labels are read twice during screen-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.
1 parent 0930dc3 commit 398ce36

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<label class="mat-optgroup-label" [id]="_labelId">{{ label }} <ng-content></ng-content></label>
1+
<span class="mat-optgroup-label" aria-hidden="true" [id]="_labelId">{{ label }} <ng-content></ng-content></span>
22
<ng-content select="mat-option, ng-container"></ng-content>

src/material/select/select.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ describe('MatSelect', () => {
11291129

11301130
it('should set the `aria-labelledby` attribute', fakeAsync(() => {
11311131
let group = groups[0];
1132-
let label = group.querySelector('label')!;
1132+
let label = group.querySelector('span')!;
11331133

11341134
expect(label.getAttribute('id')).toBeTruthy('Expected label to have an id.');
11351135
expect(group.getAttribute('aria-labelledby'))

0 commit comments

Comments
 (0)