Skip to content

Commit 6ce89aa

Browse files
crisbetoamysorto
authored andcommitted
fix(material/stepper): assistive technology reading out stepper icon (#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)
1 parent 7310914 commit 6ce89aa

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/material/stepper/step-header.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
[ngTemplateOutlet]="iconOverrides[state]"
1010
[ngTemplateOutletContext]="_getIconContext()"></ng-container>
1111
<ng-container *ngSwitchDefault [ngSwitch]="state">
12-
<span *ngSwitchCase="'number'">{{_getDefaultTextForState(state)}}</span>
12+
<span aria-hidden="true" *ngSwitchCase="'number'">{{_getDefaultTextForState(state)}}</span>
1313
<span class="cdk-visually-hidden" *ngIf="state === 'done'">{{_intl.completedLabel}}</span>
1414
<span class="cdk-visually-hidden" *ngIf="state === 'edit'">{{_intl.editableLabel}}</span>
15-
<mat-icon *ngSwitchDefault>{{_getDefaultTextForState(state)}}</mat-icon>
15+
<mat-icon aria-hidden="true" *ngSwitchDefault>{{_getDefaultTextForState(state)}}</mat-icon>
1616
</ng-container>
1717
</div>
1818
</div>

src/material/stepper/stepper.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,11 @@ describe('MatStepper', () => {
444444
stepHeaderNativeElements.every(element => element.querySelector('.mat-focus-indicator')),
445445
).toBe(true);
446446
});
447+
448+
it('should hide the header icons from assistive technology', () => {
449+
const icon = fixture.nativeElement.querySelector('.mat-step-icon span');
450+
expect(icon.getAttribute('aria-hidden')).toBe('true');
451+
});
447452
});
448453

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

0 commit comments

Comments
 (0)