From 56e703f1d44ded6c1d332d162ba374631d927b61 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Tue, 12 Jun 2018 18:54:21 +0200 Subject: [PATCH] fix(stepper): reading out wrong amount of options with NVDA on Firefox (#11711) Fixes NVDA on Firefox reading out "Tab 1 of 1" for vertical steppers. Seems to be a similar issue to #11694. --- src/lib/stepper/stepper-horizontal.html | 2 ++ src/lib/stepper/stepper-vertical.html | 2 ++ src/lib/stepper/stepper.spec.ts | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/src/lib/stepper/stepper-horizontal.html b/src/lib/stepper/stepper-horizontal.html index b7a116537b1..e3e5b27458c 100644 --- a/src/lib/stepper/stepper-horizontal.html +++ b/src/lib/stepper/stepper-horizontal.html @@ -5,6 +5,8 @@ (keydown)="_onKeydown($event)" [tabIndex]="_getFocusIndex() === i ? 0 : -1" [id]="_getStepLabelId(i)" + [attr.aria-posinset]="i + 1" + [attr.aria-setsize]="_steps.length" [attr.aria-controls]="_getStepContentId(i)" [attr.aria-selected]="selectedIndex == i" [index]="i" diff --git a/src/lib/stepper/stepper-vertical.html b/src/lib/stepper/stepper-vertical.html index 72a1f2af45c..95c1941d424 100644 --- a/src/lib/stepper/stepper-vertical.html +++ b/src/lib/stepper/stepper-vertical.html @@ -4,6 +4,8 @@ (keydown)="_onKeydown($event)" [tabIndex]="_getFocusIndex() == i ? 0 : -1" [id]="_getStepLabelId(i)" + [attr.aria-posinset]="i + 1" + [attr.aria-setsize]="_steps.length" [attr.aria-controls]="_getStepContentId(i)" [attr.aria-selected]="selectedIndex === i" [index]="i" diff --git a/src/lib/stepper/stepper.spec.ts b/src/lib/stepper/stepper.spec.ts index 0f6652649f1..961eff34282 100644 --- a/src/lib/stepper/stepper.spec.ts +++ b/src/lib/stepper/stepper.spec.ts @@ -365,6 +365,14 @@ describe('MatStepper', () => { expect(stepperComponent.selectedIndex).toBe(-1); }); + it('should set the correct aria-posinset and aria-setsize', () => { + const headers = + Array.from(fixture.nativeElement.querySelectorAll('.mat-step-header')); + + expect(headers.map(header => header.getAttribute('aria-posinset'))).toEqual(['1', '2', '3']); + expect(headers.every(header => header.getAttribute('aria-setsize') === '3')).toBe(true); + }); + }); describe('icon overrides', () => {