Skip to content

fix(material/progress-bar): Support ChromeVox #22166

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

Merged
merged 5 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/material-experimental/mdc-progress-bar/progress-bar.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<div class="mdc-linear-progress">
<!--
All children need to be hidden for screen readers in order to support ChromeVox.
More context in the issue: https://github.com/angular/components/issues/22165.
-->
<div class="mdc-linear-progress" aria-hidden="true">
<div class="mdc-linear-progress__buffer">
<div class="mdc-linear-progress__buffer-bar"></div>
<div class="mdc-linear-progress__buffer-dots"></div>
Expand Down
13 changes: 13 additions & 0 deletions src/material-experimental/mdc-progress-bar/progress-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ describe('MDC-based MatProgressBar', () => {
return TestBed.createComponent<T>(componentType);
}

// All children need to be hidden for screen readers in order to support ChromeVox.
// More context in the issue: https://github.com/angular/components/issues/22165.
it('should have elements wrapped in aria-hidden div', () => {
const fixture = createComponent(BasicProgressBar);
const host = fixture.nativeElement as Element;
const element = host.children[0];
expect(element.children.length).toBe(1);

const div = element.querySelector('div')!;
expect(div).toBeTruthy();
expect(div.getAttribute('aria-hidden')).toBe('true');
});

describe('with animation', () => {
describe('basic progress-bar', () => {
it('should apply a mode of "determinate" if no mode is provided.', () => {
Expand Down
32 changes: 19 additions & 13 deletions src/material/progress-bar/progress-bar.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<!--
The background div is named as such because it appears below the other divs and is not sized based
on values.
All children need to be hidden for screen readers in order to support ChromeVox.
More context in the issue: https://github.com/angular/components/issues/22165.
-->
<svg width="100%" height="4" focusable="false" class="mat-progress-bar-background mat-progress-bar-element">
<defs>
<pattern [id]="progressbarId" x="4" y="0" width="8" height="4" patternUnits="userSpaceOnUse">
<circle cx="2" cy="2" r="2"/>
</pattern>
</defs>
<rect [attr.fill]="_rectangleFillValue" width="100%" height="100%"/>
</svg>
<div class="mat-progress-bar-buffer mat-progress-bar-element" [ngStyle]="_bufferTransform()"></div>
<div class="mat-progress-bar-primary mat-progress-bar-fill mat-progress-bar-element" [ngStyle]="_primaryTransform()" #primaryValueBar></div>
<div class="mat-progress-bar-secondary mat-progress-bar-fill mat-progress-bar-element"></div>
<div aria-hidden="true">
<svg width="100%" height="4" focusable="false" class="mat-progress-bar-background mat-progress-bar-element">
<defs>
<pattern [id]="progressbarId" x="4" y="0" width="8" height="4" patternUnits="userSpaceOnUse">
<circle cx="2" cy="2" r="2"/>
</pattern>
</defs>
<rect [attr.fill]="_rectangleFillValue" width="100%" height="100%"/>
</svg>
<!--
The background div is named as such because it appears below the other divs and is not sized based
on values.
-->
<div class="mat-progress-bar-buffer mat-progress-bar-element" [ngStyle]="_bufferTransform()"></div>
<div class="mat-progress-bar-primary mat-progress-bar-fill mat-progress-bar-element" [ngStyle]="_primaryTransform()" #primaryValueBar></div>
<div class="mat-progress-bar-secondary mat-progress-bar-fill mat-progress-bar-element"></div>
</div>
13 changes: 13 additions & 0 deletions src/material/progress-bar/progress-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ describe('MatProgressBar', () => {
return TestBed.createComponent<T>(componentType);
}

// All children need to be hidden for screen readers in order to support ChromeVox.
// More context in the issue: https://github.com/angular/components/issues/22165.
it('should have elements wrapped in aria-hidden div', () => {
const fixture = createComponent(BasicProgressBar);
const host = fixture.nativeElement as Element;
const element = host.children[0];
expect(element.children.length).toBe(1);

const div = element.querySelector('div')!;
expect(div).toBeTruthy();
expect(div.getAttribute('aria-hidden')).toBe('true');
});

describe('with animation', () => {
describe('basic progress-bar', () => {
it('should apply a mode of "determinate" if no mode is provided.', () => {
Expand Down