@@ -485,14 +485,12 @@ describe('MatStepper', () => {
485485 expect ( stepperComponent . selectedIndex ) . toBe ( 2 ) ;
486486 } ) ;
487487
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' , ( ) => {
489489 let stepHeaderEl = fixture . debugElement . queryAll ( By . css ( 'mat-step-header' ) ) [ 1 ] . nativeElement ;
490490
491- spyOn ( stepHeaderEl , 'blur' ) ;
492- stepHeaderEl . click ( ) ;
493491 fixture . detectChanges ( ) ;
494492
495- expect ( stepHeaderEl . blur ) . toHaveBeenCalled ( ) ;
493+ expect ( stepHeaderEl . getAttribute ( 'tabindex' ) ) . toBe ( '-1' ) ;
496494 } ) ;
497495
498496 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>,
754752 let nextKey = orientation === 'vertical' ? DOWN_ARROW : RIGHT_ARROW ;
755753 let prevKey = orientation === 'vertical' ? UP_ARROW : LEFT_ARROW ;
756754
757- expect ( stepperComponent . _focusIndex ) . toBe ( 0 ) ;
755+ expect ( stepperComponent . _getFocusIndex ( ) ) . toBe ( 0 ) ;
758756 expect ( stepperComponent . selectedIndex ) . toBe ( 0 ) ;
759757
760758 let stepHeaderEl = stepHeaders [ 0 ] . nativeElement ;
761759 dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , nextKey ) ;
762760 fixture . detectChanges ( ) ;
763761
764- expect ( stepperComponent . _focusIndex )
762+ expect ( stepperComponent . _getFocusIndex ( ) )
765763 . toBe ( 1 , 'Expected index of focused step to increase by 1 after pressing the next key.' ) ;
766764 expect ( stepperComponent . selectedIndex )
767765 . toBe ( 0 , 'Expected index of selected step to remain unchanged after pressing the next key.' ) ;
@@ -770,7 +768,7 @@ function assertCorrectKeyboardInteraction(fixture: ComponentFixture<any>,
770768 dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , ENTER ) ;
771769 fixture . detectChanges ( ) ;
772770
773- expect ( stepperComponent . _focusIndex )
771+ expect ( stepperComponent . _getFocusIndex ( ) )
774772 . toBe ( 1 , 'Expected index of focused step to remain unchanged after ENTER event.' ) ;
775773 expect ( stepperComponent . selectedIndex )
776774 . toBe ( 1 ,
@@ -780,19 +778,19 @@ function assertCorrectKeyboardInteraction(fixture: ComponentFixture<any>,
780778 dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , prevKey ) ;
781779 fixture . detectChanges ( ) ;
782780
783- expect ( stepperComponent . _focusIndex )
781+ expect ( stepperComponent . _getFocusIndex ( ) )
784782 . toBe ( 0 , 'Expected index of focused step to decrease by 1 after pressing the previous key.' ) ;
785783 expect ( stepperComponent . selectedIndex ) . toBe ( 1 ,
786784 'Expected index of selected step to remain unchanged after pressing the previous key.' ) ;
787785
788786 // When the focus is on the last step and right arrow key is pressed, the focus should cycle
789787 // through to the first step.
790- stepperComponent . _focusIndex = 2 ;
788+ stepperComponent . _keyManager . updateActiveItemIndex ( 2 ) ;
791789 stepHeaderEl = stepHeaders [ 2 ] . nativeElement ;
792790 dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , nextKey ) ;
793791 fixture . detectChanges ( ) ;
794792
795- expect ( stepperComponent . _focusIndex ) . toBe ( 0 ,
793+ expect ( stepperComponent . _getFocusIndex ( ) ) . toBe ( 0 ,
796794 'Expected index of focused step to cycle through to index 0 after pressing the next key.' ) ;
797795 expect ( stepperComponent . selectedIndex )
798796 . toBe ( 1 , 'Expected index of selected step to remain unchanged after pressing the next key.' ) ;
@@ -801,19 +799,19 @@ function assertCorrectKeyboardInteraction(fixture: ComponentFixture<any>,
801799 dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , SPACE ) ;
802800 fixture . detectChanges ( ) ;
803801
804- expect ( stepperComponent . _focusIndex )
802+ expect ( stepperComponent . _getFocusIndex ( ) )
805803 . toBe ( 0 , 'Expected index of focused to remain unchanged after SPACE event.' ) ;
806804 expect ( stepperComponent . selectedIndex )
807805 . toBe ( 0 ,
808806 'Expected index of selected step to change to index of focused step after SPACE event.' ) ;
809807
810808 const endEvent = dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , END ) ;
811- expect ( stepperComponent . _focusIndex )
809+ expect ( stepperComponent . _getFocusIndex ( ) )
812810 . toBe ( stepHeaders . length - 1 , 'Expected last step to be focused when pressing END.' ) ;
813811 expect ( endEvent . defaultPrevented ) . toBe ( true , 'Expected default END action to be prevented.' ) ;
814812
815813 const homeEvent = dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , HOME ) ;
816- expect ( stepperComponent . _focusIndex )
814+ expect ( stepperComponent . _getFocusIndex ( ) )
817815 . toBe ( 0 , 'Expected first step to be focused when pressing HOME.' ) ;
818816 expect ( homeEvent . defaultPrevented ) . toBe ( true , 'Expected default HOME action to be prevented.' ) ;
819817}
@@ -823,19 +821,19 @@ function assertArrowKeyInteractionInRtl(fixture: ComponentFixture<any>,
823821 stepHeaders : DebugElement [ ] ) {
824822 let stepperComponent = fixture . debugElement . query ( By . directive ( MatStepper ) ) . componentInstance ;
825823
826- expect ( stepperComponent . _focusIndex ) . toBe ( 0 ) ;
824+ expect ( stepperComponent . _getFocusIndex ( ) ) . toBe ( 0 ) ;
827825
828826 let stepHeaderEl = stepHeaders [ 0 ] . nativeElement ;
829827 dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , LEFT_ARROW ) ;
830828 fixture . detectChanges ( ) ;
831829
832- expect ( stepperComponent . _focusIndex ) . toBe ( 1 ) ;
830+ expect ( stepperComponent . _getFocusIndex ( ) ) . toBe ( 1 ) ;
833831
834832 stepHeaderEl = stepHeaders [ 1 ] . nativeElement ;
835833 dispatchKeyboardEvent ( stepHeaderEl , 'keydown' , RIGHT_ARROW ) ;
836834 fixture . detectChanges ( ) ;
837835
838- expect ( stepperComponent . _focusIndex ) . toBe ( 0 ) ;
836+ expect ( stepperComponent . _getFocusIndex ( ) ) . toBe ( 0 ) ;
839837}
840838
841839function asyncValidator ( minLength : number , validationTrigger : Observable < any > ) : AsyncValidatorFn {
0 commit comments