Skip to content

fix(stepper): unable to tab to step content #14892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/stepper/stepper-horizontal.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

<div class="mat-horizontal-content-container">
<div *ngFor="let step of steps; let i = index"
[attr.tabindex]="selectedIndex === i ? 0 : null"
class="mat-horizontal-stepper-content" role="tabpanel"
[@stepTransition]="_getAnimationDirection(i)"
(@stepTransition.done)="_animationDone.next($event)"
Expand Down
1 change: 1 addition & 0 deletions src/lib/stepper/stepper-vertical.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

<div class="mat-vertical-content-container" [class.mat-stepper-vertical-line]="!isLast">
<div class="mat-vertical-stepper-content" role="tabpanel"
[attr.tabindex]="selectedIndex === i ? 0 : null"
[@stepTransition]="_getAnimationDirection(i)"
(@stepTransition.done)="_animationDone.next($event)"
[id]="_getStepContentId(i)"
Expand Down
11 changes: 8 additions & 3 deletions src/lib/stepper/stepper.scss
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,13 @@ $mat-stepper-line-gap: 8px !default;
}
}

.mat-horizontal-stepper-content[aria-expanded='false'] {
height: 0;
overflow: hidden;
.mat-horizontal-stepper-content {
outline: 0;

&[aria-expanded='false'] {
height: 0;
overflow: hidden;
}
}

.mat-horizontal-content-container {
Expand Down Expand Up @@ -162,6 +166,7 @@ $mat-stepper-line-gap: 8px !default;

.mat-vertical-stepper-content {
overflow: hidden;
outline: 0;
}

.mat-vertical-content {
Expand Down
17 changes: 17 additions & 0 deletions src/lib/stepper/stepper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,23 @@ describe('MatStepper', () => {
const stepHeaders = fixture.debugElement.queryAll(By.css('.mat-vertical-stepper-header'));
assertSelectKeyWithModifierInteraction(fixture, stepHeaders, 'vertical', SPACE);
});

it('should set the proper tabindex', () => {
let stepContents = fixture.debugElement.queryAll(By.css(`.mat-vertical-stepper-content`));
let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance;
let firstStepContentEl = stepContents[0].nativeElement;
let secondStepContentEl = stepContents[1].nativeElement;

expect(firstStepContentEl.getAttribute('tabindex')).toBe('0');
expect(secondStepContentEl.getAttribute('tabindex')).toBeFalsy();

stepperComponent.selectedIndex = 1;
fixture.detectChanges();

expect(firstStepContentEl.getAttribute('tabindex')).toBeFalsy();
expect(secondStepContentEl.getAttribute('tabindex')).toBe('0');
});

});

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