@@ -75,6 +75,12 @@ describe('MdHorizontalStepper', () => {
75
75
let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) ;
76
76
checkKeyboardEvent ( stepperComponent , fixture , stepHeaders ) ;
77
77
} ) ;
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
+ } ) ;
78
84
} ) ;
79
85
80
86
describe ( 'linear horizontal stepper' , ( ) => {
@@ -105,6 +111,12 @@ describe('MdHorizontalStepper', () => {
105
111
. queryAll ( By . css ( '.mat-horizontal-stepper-header' ) ) [ 1 ] . nativeElement ;
106
112
checkLinearStepperValidity ( stepHeaderEl , stepperComponent , testComponent , fixture ) ;
107
113
} ) ;
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
+ } ) ;
108
120
} ) ;
109
121
} ) ;
110
122
@@ -173,6 +185,12 @@ describe('MdVerticalStepper', () => {
173
185
let stepHeaders = fixture . debugElement . queryAll ( By . css ( '.mat-vertical-stepper-header' ) ) ;
174
186
checkKeyboardEvent ( stepperComponent , fixture , stepHeaders ) ;
175
187
} ) ;
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
+ } ) ;
176
194
} ) ;
177
195
178
196
describe ( 'linear vertical stepper' , ( ) => {
@@ -204,6 +222,12 @@ describe('MdVerticalStepper', () => {
204
222
205
223
checkLinearStepperValidity ( stepHeaderEl , stepperComponent , testComponent , fixture ) ;
206
224
} ) ;
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
+ } ) ;
207
231
} ) ;
208
232
} ) ;
209
233
@@ -387,6 +411,19 @@ function checkKeyboardEvent(stepperComponent: MdStepper,
387
411
'Expected index of selected step to change to index of focused step after SPACE event.' ) ;
388
412
}
389
413
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
+
390
427
function checkLinearStepperValidity ( stepHeaderEl : HTMLElement ,
391
428
stepperComponent : MdStepper ,
392
429
testComponent :
@@ -412,6 +449,14 @@ function checkLinearStepperValidity(stepHeaderEl: HTMLElement,
412
449
expect ( stepperComponent . selectedIndex ) . toBe ( 1 ) ;
413
450
}
414
451
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
+
415
460
@Component ( {
416
461
template : `
417
462
<md-horizontal-stepper>
0 commit comments