Skip to content

Commit

Permalink
fix(material/stepper): assistive technology reading out stepper icon (#…
Browse files Browse the repository at this point in the history
…24025)

Fixes that the text inside the icon was being read out when the user interacts with the stepper header using assistive technology.

(cherry picked from commit 470abdf)
  • Loading branch information
crisbeto authored and amysorto committed Dec 14, 2021
1 parent 7310914 commit 6ce89aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/material/stepper/step-header.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
[ngTemplateOutlet]="iconOverrides[state]"
[ngTemplateOutletContext]="_getIconContext()"></ng-container>
<ng-container *ngSwitchDefault [ngSwitch]="state">
<span *ngSwitchCase="'number'">{{_getDefaultTextForState(state)}}</span>
<span aria-hidden="true" *ngSwitchCase="'number'">{{_getDefaultTextForState(state)}}</span>
<span class="cdk-visually-hidden" *ngIf="state === 'done'">{{_intl.completedLabel}}</span>
<span class="cdk-visually-hidden" *ngIf="state === 'edit'">{{_intl.editableLabel}}</span>
<mat-icon *ngSwitchDefault>{{_getDefaultTextForState(state)}}</mat-icon>
<mat-icon aria-hidden="true" *ngSwitchDefault>{{_getDefaultTextForState(state)}}</mat-icon>
</ng-container>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions src/material/stepper/stepper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,11 @@ describe('MatStepper', () => {
stepHeaderNativeElements.every(element => element.querySelector('.mat-focus-indicator')),
).toBe(true);
});

it('should hide the header icons from assistive technology', () => {
const icon = fixture.nativeElement.querySelector('.mat-step-icon span');
expect(icon.getAttribute('aria-hidden')).toBe('true');
});
});

describe('basic stepper when attempting to set the selected step too early', () => {
Expand Down

0 comments on commit 6ce89aa

Please sign in to comment.