@@ -179,9 +179,7 @@ export class CdkStepper implements AfterViewInit, OnDestroy {
179
179
if ( this . _selectedIndex != index &&
180
180
! this . _anyControlsInvalidOrPending ( index ) &&
181
181
( index >= this . _selectedIndex || this . _steps . toArray ( ) [ index ] . editable ) ) {
182
-
183
- this . _emitStepperSelectionEvent ( index ) ;
184
- this . _keyManager . updateActiveItemIndex ( this . _selectedIndex ) ;
182
+ this . _updateSelectedItemIndex ( index ) ;
185
183
}
186
184
} else {
187
185
this . _selectedIndex = index ;
@@ -237,7 +235,7 @@ export class CdkStepper implements AfterViewInit, OnDestroy {
237
235
238
236
/** Resets the stepper to its initial state. Note that this includes clearing form data. */
239
237
reset ( ) : void {
240
- this . selectedIndex = 0 ;
238
+ this . _updateSelectedItemIndex ( 0 ) ;
241
239
this . _steps . forEach ( step => step . reset ( ) ) ;
242
240
this . _stateChanged ( ) ;
243
241
}
@@ -283,14 +281,15 @@ export class CdkStepper implements AfterViewInit, OnDestroy {
283
281
return this . _keyManager ? this . _keyManager . activeItemIndex : this . _selectedIndex ;
284
282
}
285
283
286
- private _emitStepperSelectionEvent ( newIndex : number ) : void {
284
+ private _updateSelectedItemIndex ( newIndex : number ) : void {
287
285
const stepsArray = this . _steps . toArray ( ) ;
288
286
this . selectionChange . emit ( {
289
287
selectedIndex : newIndex ,
290
288
previouslySelectedIndex : this . _selectedIndex ,
291
289
selectedStep : stepsArray [ newIndex ] ,
292
290
previouslySelectedStep : stepsArray [ this . _selectedIndex ] ,
293
291
} ) ;
292
+ this . _keyManager . updateActiveItemIndex ( newIndex ) ;
294
293
this . _selectedIndex = newIndex ;
295
294
this . _stateChanged ( ) ;
296
295
}
0 commit comments