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/progress-spinner): resolve accessibility issue in ChromeVox #22219

Merged
merged 1 commit 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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
</svg>
</ng-template>

<div class="mdc-circular-progress__determinate-container" #determinateSpinner>
<!--
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-circular-progress__determinate-container" aria-hidden="true" #determinateSpinner>
<svg [attr.viewBox]="_viewBox()" class="mdc-circular-progress__determinate-circle-graphic"
xmlns="http://www.w3.org/2000/svg" focusable="false">
<circle [attr.r]="_circleRadius()"
Expand All @@ -21,7 +25,7 @@
</svg>
</div>
<!--TODO: figure out why there are 3 separate svgs-->
<div class="mdc-circular-progress__indeterminate-container">
<div class="mdc-circular-progress__indeterminate-container" aria-hidden="true">
<div class="mdc-circular-progress__spinner-layer">
<div class="mdc-circular-progress__circle-clipper mdc-circular-progress__circle-left">
<ng-container [ngTemplateOutlet]="circle"></ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,18 @@ describe('MDC-based MatProgressSpinner', () => {

expect(progressElement.nativeElement.hasAttribute('aria-valuenow')).toBe(false);
});

it('should apply aria-hidden to child nodes', () => {
const fixture = TestBed.createComponent(BasicProgressSpinner);
fixture.detectChanges();

const progressElement = fixture.nativeElement.querySelector('mat-progress-spinner');
const children = Array.from<HTMLElement>(progressElement.children);

expect(children.length).toBeGreaterThan(0);
expect(children.every(child => child.getAttribute('aria-hidden') === 'true')).toBe(true);
});

});


Expand Down
8 changes: 6 additions & 2 deletions src/material/progress-spinner/progress-spinner.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
element containing the SVG. `focusable="false"` prevents IE from allowing the user to
tab into the SVG element.
-->

<!--
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
[style.width.px]="diameter"
[style.height.px]="diameter"
[attr.viewBox]="_getViewBox()"
preserveAspectRatio="xMidYMid meet"
focusable="false"
[ngSwitch]="mode === 'indeterminate'">
[ngSwitch]="mode === 'indeterminate'"
aria-hidden="true">

<!--
Technically we can reuse the same `circle` element, however Safari has an issue that breaks
Expand Down
11 changes: 11 additions & 0 deletions src/material/progress-spinner/progress-spinner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,17 @@ describe('MatProgressSpinner', () => {
expect(shadowRoot.querySelector('style[mat-spinner-animation="27"]')).toBeTruthy();
});

it('should apply aria-hidden to child nodes', () => {
const fixture = TestBed.createComponent(BasicProgressSpinner);
fixture.detectChanges();

const progressElement = fixture.nativeElement.querySelector('mat-progress-spinner');
const children = Array.from<HTMLElement>(progressElement.children);

expect(children.length).toBeGreaterThan(0);
expect(children.every(child => child.getAttribute('aria-hidden') === 'true')).toBe(true);
});

});


Expand Down