@@ -75,6 +75,12 @@ describe('MdHorizontalStepper', () => {
7575      let  stepHeaders  =  fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ; 
7676      checkKeyboardEvent ( stepperComponent ,  fixture ,  stepHeaders ) ; 
7777    } ) ; 
78+ 
79+     it ( 'should not set focus on header of selected step if header is not clicked' ,  ( )  =>  { 
80+       let  stepHeaderEl  =  fixture . debugElement 
81+           . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) [ 1 ] . nativeElement ; 
82+       checkStepHeaderFocusNotCalled ( stepHeaderEl ,  stepperComponent ,  fixture ) ; 
83+     } ) ; 
7884  } ) ; 
7985
8086  describe ( 'linear horizontal stepper' ,  ( )  =>  { 
@@ -105,6 +111,12 @@ describe('MdHorizontalStepper', () => {
105111          . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) [ 1 ] . nativeElement ; 
106112      checkLinearStepperValidity ( stepHeaderEl ,  stepperComponent ,  testComponent ,  fixture ) ; 
107113    } ) ; 
114+ 
115+     it ( 'should not focus step header upon click if it is not able to be selected' ,  ( )  =>  { 
116+       let  stepHeaderEl  =  fixture . debugElement 
117+           . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) [ 1 ] . nativeElement ; 
118+       checkStepHeaderBlur ( stepHeaderEl ,  fixture ) ; 
119+     } ) ; 
108120  } ) ; 
109121} ) ; 
110122
@@ -173,6 +185,12 @@ describe('MdVerticalStepper', () => {
173185      let  stepHeaders  =  fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ; 
174186      checkKeyboardEvent ( stepperComponent ,  fixture ,  stepHeaders ) ; 
175187    } ) ; 
188+ 
189+     it ( 'should not set focus on header of selected step if header is not clicked' ,  ( )  =>  { 
190+       let  stepHeaderEl  =  fixture . debugElement 
191+           . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) [ 1 ] . nativeElement ; 
192+       checkStepHeaderFocusNotCalled ( stepHeaderEl ,  stepperComponent ,  fixture ) ; 
193+     } ) ; 
176194  } ) ; 
177195
178196  describe ( 'linear vertical stepper' ,  ( )  =>  { 
@@ -204,6 +222,12 @@ describe('MdVerticalStepper', () => {
204222
205223      checkLinearStepperValidity ( stepHeaderEl ,  stepperComponent ,  testComponent ,  fixture ) ; 
206224    } ) ; 
225+ 
226+     it ( 'should not focus step header upon click if it is not able to be selected' ,  ( )  =>  { 
227+       let  stepHeaderEl  =  fixture . debugElement 
228+           . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) [ 1 ] . nativeElement ; 
229+       checkStepHeaderBlur ( stepHeaderEl ,  fixture ) ; 
230+     } ) ; 
207231  } ) ; 
208232} ) ; 
209233
@@ -387,6 +411,19 @@ function checkKeyboardEvent(stepperComponent: MdStepper,
387411          'Expected index of selected step to change to index of focused step after SPACE event.' ) ; 
388412} 
389413
414+ function  checkStepHeaderFocusNotCalled ( stepHeaderEl : HTMLElement , 
415+                                        stepperComponent : MdStepper , 
416+                                        fixture : ComponentFixture < any > )  { 
417+   let  nextButtonNativeEl  =  fixture . debugElement 
418+       . queryAll ( By . directive ( MdStepperNext ) ) [ 0 ] . nativeElement ; 
419+   spyOn ( stepHeaderEl ,  'focus' ) ; 
420+   nextButtonNativeEl . click ( ) ; 
421+   fixture . detectChanges ( ) ; 
422+ 
423+   expect ( stepperComponent . selectedIndex ) . toBe ( 1 ) ; 
424+   expect ( stepHeaderEl . focus ) . not . toHaveBeenCalled ( ) ; 
425+ } 
426+ 
390427function  checkLinearStepperValidity ( stepHeaderEl : HTMLElement , 
391428                                    stepperComponent : MdStepper , 
392429                                    testComponent :
@@ -412,6 +449,14 @@ function checkLinearStepperValidity(stepHeaderEl: HTMLElement,
412449  expect ( stepperComponent . selectedIndex ) . toBe ( 1 ) ; 
413450} 
414451
452+ function  checkStepHeaderBlur ( stepHeaderEl : HTMLElement ,  fixture : ComponentFixture < any > )  { 
453+   spyOn ( stepHeaderEl ,  'blur' ) ; 
454+   stepHeaderEl . click ( ) ; 
455+   fixture . detectChanges ( ) ; 
456+ 
457+   expect ( stepHeaderEl . blur ) . toHaveBeenCalled ( ) ; 
458+ } 
459+ 
415460@Component ( { 
416461  template : ` 
417462    <md-horizontal-stepper> 
0 commit comments