Skip to content

Commit 5b7b03e

Browse files
authored
fix(material/progress-bar): Support ChromeVox (#22166)
* fix(material/progress-bar): Support ChromeVox * refactor(material/progress-bar): wrap elements with aria-hidden div * fix(material-experimental/mdc-progress-bar): Support ChromeVox #22165 * test(material/progress-bar): add ChromeVox support tests * test(material-experimental/mdc-progress-bar): add ChromeVox support test
1 parent 902e946 commit 5b7b03e

File tree

4 files changed

+50
-14
lines changed

4 files changed

+50
-14
lines changed

src/material-experimental/mdc-progress-bar/progress-bar.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
<div class="mdc-linear-progress">
1+
<!--
2+
All children need to be hidden for screen readers in order to support ChromeVox.
3+
More context in the issue: https://github.com/angular/components/issues/22165.
4+
-->
5+
<div class="mdc-linear-progress" aria-hidden="true">
26
<div class="mdc-linear-progress__buffer">
37
<div class="mdc-linear-progress__buffer-bar"></div>
48
<div class="mdc-linear-progress__buffer-dots"></div>

src/material-experimental/mdc-progress-bar/progress-bar.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ describe('MDC-based MatProgressBar', () => {
1717
return TestBed.createComponent<T>(componentType);
1818
}
1919

20+
// All children need to be hidden for screen readers in order to support ChromeVox.
21+
// More context in the issue: https://github.com/angular/components/issues/22165.
22+
it('should have elements wrapped in aria-hidden div', () => {
23+
const fixture = createComponent(BasicProgressBar);
24+
const host = fixture.nativeElement as Element;
25+
const element = host.children[0];
26+
expect(element.children.length).toBe(1);
27+
28+
const div = element.querySelector('div')!;
29+
expect(div).toBeTruthy();
30+
expect(div.getAttribute('aria-hidden')).toBe('true');
31+
});
32+
2033
describe('with animation', () => {
2134
describe('basic progress-bar', () => {
2235
it('should apply a mode of "determinate" if no mode is provided.', () => {
Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
<!--
2-
The background div is named as such because it appears below the other divs and is not sized based
3-
on values.
2+
All children need to be hidden for screen readers in order to support ChromeVox.
3+
More context in the issue: https://github.com/angular/components/issues/22165.
44
-->
5-
<svg width="100%" height="4" focusable="false" class="mat-progress-bar-background mat-progress-bar-element">
6-
<defs>
7-
<pattern [id]="progressbarId" x="4" y="0" width="8" height="4" patternUnits="userSpaceOnUse">
8-
<circle cx="2" cy="2" r="2"/>
9-
</pattern>
10-
</defs>
11-
<rect [attr.fill]="_rectangleFillValue" width="100%" height="100%"/>
12-
</svg>
13-
<div class="mat-progress-bar-buffer mat-progress-bar-element" [ngStyle]="_bufferTransform()"></div>
14-
<div class="mat-progress-bar-primary mat-progress-bar-fill mat-progress-bar-element" [ngStyle]="_primaryTransform()" #primaryValueBar></div>
15-
<div class="mat-progress-bar-secondary mat-progress-bar-fill mat-progress-bar-element"></div>
5+
<div aria-hidden="true">
6+
<svg width="100%" height="4" focusable="false" class="mat-progress-bar-background mat-progress-bar-element">
7+
<defs>
8+
<pattern [id]="progressbarId" x="4" y="0" width="8" height="4" patternUnits="userSpaceOnUse">
9+
<circle cx="2" cy="2" r="2"/>
10+
</pattern>
11+
</defs>
12+
<rect [attr.fill]="_rectangleFillValue" width="100%" height="100%"/>
13+
</svg>
14+
<!--
15+
The background div is named as such because it appears below the other divs and is not sized based
16+
on values.
17+
-->
18+
<div class="mat-progress-bar-buffer mat-progress-bar-element" [ngStyle]="_bufferTransform()"></div>
19+
<div class="mat-progress-bar-primary mat-progress-bar-fill mat-progress-bar-element" [ngStyle]="_primaryTransform()" #primaryValueBar></div>
20+
<div class="mat-progress-bar-secondary mat-progress-bar-fill mat-progress-bar-element"></div>
21+
</div>

src/material/progress-bar/progress-bar.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ describe('MatProgressBar', () => {
2525
return TestBed.createComponent<T>(componentType);
2626
}
2727

28+
// All children need to be hidden for screen readers in order to support ChromeVox.
29+
// More context in the issue: https://github.com/angular/components/issues/22165.
30+
it('should have elements wrapped in aria-hidden div', () => {
31+
const fixture = createComponent(BasicProgressBar);
32+
const host = fixture.nativeElement as Element;
33+
const element = host.children[0];
34+
expect(element.children.length).toBe(1);
35+
36+
const div = element.querySelector('div')!;
37+
expect(div).toBeTruthy();
38+
expect(div.getAttribute('aria-hidden')).toBe('true');
39+
});
40+
2841
describe('with animation', () => {
2942
describe('basic progress-bar', () => {
3043
it('should apply a mode of "determinate" if no mode is provided.', () => {

0 commit comments

Comments
 (0)