Skip to content

Commit 9582b8b

Browse files
crisbetotinayuangao
authored andcommitted
fix(stepper): set appropriate aria-orientation (#8657)
Based on the accessibility guidelines (https://www.w3.org/TR/wai-aria-1.1/#tablist), tab lists (which the stepper uses internally) can have an `aria-orientation`. Since we have both vertical and horizontal steppers, these changes set the appropriate `aria-orientation` in order to match the stepper's orientation.
1 parent 74c1d01 commit 9582b8b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/lib/stepper/stepper.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ describe('MatHorizontalStepper', () => {
5656
expect(stepperEl.getAttribute('role')).toBe('tablist');
5757
});
5858

59+
it('should set the proper "aria-orientation"', () => {
60+
let stepperEl = fixture.debugElement.query(By.css('mat-horizontal-stepper')).nativeElement;
61+
expect(stepperEl.getAttribute('aria-orientation')).toBe('horizontal');
62+
});
63+
5964
it('should set aria-expanded of content correctly', () => {
6065
let stepContents = fixture.debugElement.queryAll(By.css(`.mat-horizontal-stepper-content`));
6166
assertCorrectAriaExpandedAttribute(fixture, stepContents);
@@ -227,6 +232,11 @@ describe('MatVerticalStepper', () => {
227232
expect(stepperEl.getAttribute('role')).toBe('tablist');
228233
});
229234

235+
it('should set the proper "aria-orientation"', () => {
236+
let stepperEl = fixture.debugElement.query(By.css('mat-vertical-stepper')).nativeElement;
237+
expect(stepperEl.getAttribute('aria-orientation')).toBe('vertical');
238+
});
239+
230240
it('should set aria-expanded of content correctly', () => {
231241
let stepContents = fixture.debugElement.queryAll(By.css(`.mat-vertical-stepper-content`));
232242
assertCorrectAriaExpandedAttribute(fixture, stepContents);

src/lib/stepper/stepper.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export class MatStepper extends _MatStepper implements AfterContentInit {
9090
inputs: ['selectedIndex'],
9191
host: {
9292
'class': 'mat-stepper-horizontal',
93+
'aria-orientation': 'horizontal',
9394
'role': 'tablist',
9495
},
9596
animations: [
@@ -116,6 +117,7 @@ export class MatHorizontalStepper extends MatStepper { }
116117
inputs: ['selectedIndex'],
117118
host: {
118119
'class': 'mat-stepper-vertical',
120+
'aria-orientation': 'vertical',
119121
'role': 'tablist',
120122
},
121123
animations: [

0 commit comments

Comments
 (0)