Skip to content

Commit

Permalink
fix(stepper): set appropriate aria-orientation (#8657)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
crisbeto authored and tinayuangao committed Dec 1, 2017
1 parent 74c1d01 commit 9582b8b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib/stepper/stepper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ describe('MatHorizontalStepper', () => {
expect(stepperEl.getAttribute('role')).toBe('tablist');
});

it('should set the proper "aria-orientation"', () => {
let stepperEl = fixture.debugElement.query(By.css('mat-horizontal-stepper')).nativeElement;
expect(stepperEl.getAttribute('aria-orientation')).toBe('horizontal');
});

it('should set aria-expanded of content correctly', () => {
let stepContents = fixture.debugElement.queryAll(By.css(`.mat-horizontal-stepper-content`));
assertCorrectAriaExpandedAttribute(fixture, stepContents);
Expand Down Expand Up @@ -227,6 +232,11 @@ describe('MatVerticalStepper', () => {
expect(stepperEl.getAttribute('role')).toBe('tablist');
});

it('should set the proper "aria-orientation"', () => {
let stepperEl = fixture.debugElement.query(By.css('mat-vertical-stepper')).nativeElement;
expect(stepperEl.getAttribute('aria-orientation')).toBe('vertical');
});

it('should set aria-expanded of content correctly', () => {
let stepContents = fixture.debugElement.queryAll(By.css(`.mat-vertical-stepper-content`));
assertCorrectAriaExpandedAttribute(fixture, stepContents);
Expand Down
2 changes: 2 additions & 0 deletions src/lib/stepper/stepper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export class MatStepper extends _MatStepper implements AfterContentInit {
inputs: ['selectedIndex'],
host: {
'class': 'mat-stepper-horizontal',
'aria-orientation': 'horizontal',
'role': 'tablist',
},
animations: [
Expand All @@ -116,6 +117,7 @@ export class MatHorizontalStepper extends MatStepper { }
inputs: ['selectedIndex'],
host: {
'class': 'mat-stepper-vertical',
'aria-orientation': 'vertical',
'role': 'tablist',
},
animations: [
Expand Down

0 comments on commit 9582b8b

Please sign in to comment.