From 9a771648f6cd942d04e99bf78b36c989b8a822a3 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Tue, 5 Mar 2019 20:29:57 +0100 Subject: [PATCH] fix(stepper): unable to tab to step content (#14892) Along the same line as #14808. Fixes not being able to reach the content of a step if it doesn't have focusable content already. Based on the [tabs example from the accessibility guidelines](https://www.w3.org/TR/wai-aria-practices-1.1/examples/tabs/tabs-2/tabs.html). --- src/lib/stepper/stepper-horizontal.html | 1 + src/lib/stepper/stepper-vertical.html | 1 + src/lib/stepper/stepper.scss | 11 ++++++++--- src/lib/stepper/stepper.spec.ts | 17 +++++++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/lib/stepper/stepper-horizontal.html b/src/lib/stepper/stepper-horizontal.html index 9f9935264af..142df9aa03a 100644 --- a/src/lib/stepper/stepper-horizontal.html +++ b/src/lib/stepper/stepper-horizontal.html @@ -27,6 +27,7 @@
{ 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', () => {