@@ -485,14 +485,12 @@ describe('MatStepper', () => {
485
485
expect ( stepperComponent . selectedIndex ) . toBe ( 2 ) ;
486
486
} ) ;
487
487
488
- it ( 'should not focus step header upon click if it is not able to be selected' , ( ) => {
488
+ it ( 'should be able to focus step header upon click if it is unable to be selected' , ( ) => {
489
489
let stepHeaderEl = fixture . debugElement . queryAll ( By . css ( 'mat-step-header' ) ) [ 1 ] . nativeElement ;
490
490
491
- spyOn ( stepHeaderEl , 'blur' ) ;
492
- stepHeaderEl . click ( ) ;
493
491
fixture . detectChanges ( ) ;
494
492
495
- expect ( stepHeaderEl . blur ) . toHaveBeenCalled ( ) ;
493
+ expect ( stepHeaderEl . getAttribute ( 'tabindex' ) ) . toBe ( '-1' ) ;
496
494
} ) ;
497
495
498
496
it ( 'should be able to move to next step even when invalid if current step is optional' , ( ) => {
@@ -754,14 +752,14 @@ function assertCorrectKeyboardInteraction(fixture: ComponentFixture<any>,
754
752
let nextKey = orientation === 'vertical' ? DOWN_ARROW : RIGHT_ARROW ;
755
753
let prevKey = orientation === 'vertical' ? UP_ARROW : LEFT_ARROW ;
756
754
757
- expect ( stepperComponent . _focusIndex ) . toBe ( 0 ) ;
755
+ expect ( stepperComponent . _getFocusIndex ( ) ) . toBe ( 0 ) ;
758
756
expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
759
757
760
758
let stepHeaderEl = stepHeaders [ 0 ] . nativeElement ;
761
759
dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , nextKey ) ;
762
760
fixture . detectChanges ( ) ;
763
761
764
- expect ( stepperComponent . _focusIndex )
762
+ expect ( stepperComponent . _getFocusIndex ( ) )
765
763
. toBe ( 1 , 'Expected index of focused step to increase by 1 after pressing the next key.' ) ;
766
764
expect ( stepperComponent . selectedIndex )
767
765
. toBe ( 0 , 'Expected index of selected step to remain unchanged after pressing the next key.' ) ;
@@ -770,7 +768,7 @@ function assertCorrectKeyboardInteraction(fixture: ComponentFixture<any>,
770
768
dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , ENTER ) ;
771
769
fixture . detectChanges ( ) ;
772
770
773
- expect ( stepperComponent . _focusIndex )
771
+ expect ( stepperComponent . _getFocusIndex ( ) )
774
772
. toBe ( 1 , 'Expected index of focused step to remain unchanged after ENTER event.' ) ;
775
773
expect ( stepperComponent . selectedIndex )
776
774
. toBe ( 1 ,
@@ -780,19 +778,19 @@ function assertCorrectKeyboardInteraction(fixture: ComponentFixture<any>,
780
778
dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , prevKey ) ;
781
779
fixture . detectChanges ( ) ;
782
780
783
- expect ( stepperComponent . _focusIndex )
781
+ expect ( stepperComponent . _getFocusIndex ( ) )
784
782
. toBe ( 0 , 'Expected index of focused step to decrease by 1 after pressing the previous key.' ) ;
785
783
expect ( stepperComponent . selectedIndex ) . toBe ( 1 ,
786
784
'Expected index of selected step to remain unchanged after pressing the previous key.' ) ;
787
785
788
786
// When the focus is on the last step and right arrow key is pressed, the focus should cycle
789
787
// through to the first step.
790
- stepperComponent . _focusIndex = 2 ;
788
+ stepperComponent . _keyManager . updateActiveItemIndex ( 2 ) ;
791
789
stepHeaderEl = stepHeaders [ 2 ] . nativeElement ;
792
790
dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , nextKey ) ;
793
791
fixture . detectChanges ( ) ;
794
792
795
- expect ( stepperComponent . _focusIndex ) . toBe ( 0 ,
793
+ expect ( stepperComponent . _getFocusIndex ( ) ) . toBe ( 0 ,
796
794
'Expected index of focused step to cycle through to index 0 after pressing the next key.' ) ;
797
795
expect ( stepperComponent . selectedIndex )
798
796
. toBe ( 1 , 'Expected index of selected step to remain unchanged after pressing the next key.' ) ;
@@ -801,19 +799,19 @@ function assertCorrectKeyboardInteraction(fixture: ComponentFixture<any>,
801
799
dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , SPACE ) ;
802
800
fixture . detectChanges ( ) ;
803
801
804
- expect ( stepperComponent . _focusIndex )
802
+ expect ( stepperComponent . _getFocusIndex ( ) )
805
803
. toBe ( 0 , 'Expected index of focused to remain unchanged after SPACE event.' ) ;
806
804
expect ( stepperComponent . selectedIndex )
807
805
. toBe ( 0 ,
808
806
'Expected index of selected step to change to index of focused step after SPACE event.' ) ;
809
807
810
808
const endEvent = dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , END ) ;
811
- expect ( stepperComponent . _focusIndex )
809
+ expect ( stepperComponent . _getFocusIndex ( ) )
812
810
. toBe ( stepHeaders . length - 1 , 'Expected last step to be focused when pressing END.' ) ;
813
811
expect ( endEvent . defaultPrevented ) . toBe ( true , 'Expected default END action to be prevented.' ) ;
814
812
815
813
const homeEvent = dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , HOME ) ;
816
- expect ( stepperComponent . _focusIndex )
814
+ expect ( stepperComponent . _getFocusIndex ( ) )
817
815
. toBe ( 0 , 'Expected first step to be focused when pressing HOME.' ) ;
818
816
expect ( homeEvent . defaultPrevented ) . toBe ( true , 'Expected default HOME action to be prevented.' ) ;
819
817
}
@@ -823,19 +821,19 @@ function assertArrowKeyInteractionInRtl(fixture: ComponentFixture<any>,
823
821
stepHeaders : DebugElement [ ] ) {
824
822
let stepperComponent = fixture . debugElement . query ( By . directive ( MatStepper ) ) . componentInstance ;
825
823
826
- expect ( stepperComponent . _focusIndex ) . toBe ( 0 ) ;
824
+ expect ( stepperComponent . _getFocusIndex ( ) ) . toBe ( 0 ) ;
827
825
828
826
let stepHeaderEl = stepHeaders [ 0 ] . nativeElement ;
829
827
dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , LEFT_ARROW ) ;
830
828
fixture . detectChanges ( ) ;
831
829
832
- expect ( stepperComponent . _focusIndex ) . toBe ( 1 ) ;
830
+ expect ( stepperComponent . _getFocusIndex ( ) ) . toBe ( 1 ) ;
833
831
834
832
stepHeaderEl = stepHeaders [ 1 ] . nativeElement ;
835
833
dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , RIGHT_ARROW ) ;
836
834
fixture . detectChanges ( ) ;
837
835
838
- expect ( stepperComponent . _focusIndex ) . toBe ( 0 ) ;
836
+ expect ( stepperComponent . _getFocusIndex ( ) ) . toBe ( 0 ) ;
839
837
}
840
838
841
839
function asyncValidator ( minLength : number , validationTrigger : Observable < any > ) : AsyncValidatorFn {
0 commit comments