@@ -24,7 +24,10 @@ import {
2424 ViewEncapsulation ,
2525 Optional ,
2626 Inject ,
27- forwardRef
27+ forwardRef ,
28+ ChangeDetectionStrategy ,
29+ ChangeDetectorRef ,
30+ OnChanges ,
2831} from '@angular/core' ;
2932import { LEFT_ARROW , RIGHT_ARROW , ENTER , SPACE } from '@angular/cdk/keycodes' ;
3033import { CdkStepLabel } from './step-label' ;
@@ -62,8 +65,9 @@ export class StepperSelectionEvent {
6265 templateUrl : 'step.html' ,
6366 encapsulation : ViewEncapsulation . None ,
6467 preserveWhitespaces : false ,
68+ changeDetection : ChangeDetectionStrategy . OnPush ,
6569} )
66- export class CdkStep {
70+ export class CdkStep implements OnChanges {
6771 /** Template for step label if it exists. */
6872 @ContentChild ( CdkStepLabel ) stepLabel : CdkStepLabel ;
6973
@@ -73,12 +77,11 @@ export class CdkStep {
7377 /** The top level abstract control of the step. */
7478 @Input ( ) stepControl : AbstractControl ;
7579
76- /** Whether user has seen the expanded step content or not . */
80+ /** Whether user has seen the expanded step content or not. */
7781 interacted = false ;
7882
7983 /** Label of the step. */
80- @Input ( )
81- label : string ;
84+ @Input ( ) label : string ;
8285
8386 @Input ( )
8487 get editable ( ) { return this . _editable ; }
@@ -115,6 +118,12 @@ export class CdkStep {
115118 select ( ) : void {
116119 this . _stepper . selected = this ;
117120 }
121+
122+ ngOnChanges ( ) {
123+ // Since basically all inputs of the MdStep get proxied through the view down to the
124+ // underlying MdStepHeader, we have to make sure that change detection runs correctly.
125+ this . _stepper . _stateChanged ( ) ;
126+ }
118127}
119128
120129@Directive ( {
@@ -164,7 +173,9 @@ export class CdkStepper {
164173 /** Used to track unique ID for each stepper component. */
165174 _groupId : number ;
166175
167- constructor ( @Optional ( ) private _dir : Directionality ) {
176+ constructor (
177+ @Optional ( ) private _dir : Directionality ,
178+ private _changeDetectorRef : ChangeDetectorRef ) {
168179 this . _groupId = nextId ++ ;
169180 }
170181
@@ -188,6 +199,11 @@ export class CdkStepper {
188199 return `mat-step-content-${ this . _groupId } -${ i } ` ;
189200 }
190201
202+ /** Marks the component to be change detected. */
203+ _stateChanged ( ) {
204+ this . _changeDetectorRef . markForCheck ( ) ;
205+ }
206+
191207 /** Returns position state of the step with the given index. */
192208 _getAnimationDirection ( index : number ) : StepContentPositionState {
193209 const position = index - this . _selectedIndex ;
@@ -218,6 +234,7 @@ export class CdkStepper {
218234 previouslySelectedStep : stepsArray [ this . _selectedIndex ] ,
219235 } ) ;
220236 this . _selectedIndex = newIndex ;
237+ this . _stateChanged ( ) ;
221238 }
222239
223240 _onKeydown ( event : KeyboardEvent ) {
0 commit comments