@@ -24,6 +24,7 @@ import {
2424} from '@angular/core' ;
2525import { LEFT_ARROW , RIGHT_ARROW , ENTER , SPACE } from '@angular/cdk/keyboard' ;
2626import { CdkStepLabel } from './step-label' ;
27+ import { coerceBooleanProperty } from '@angular/cdk/coercion' ;
2728
2829/** Used to generate unique ID for each stepper component. */
2930let nextId = 0 ;
@@ -54,6 +55,21 @@ export class CdkStep {
5455 /** Template for step content. */
5556 @ViewChild ( TemplateRef ) content : TemplateRef < any > ;
5657
58+ /** Whether step is disabled or not. */
59+ @Input ( )
60+ get disabled ( ) { return this . _disabled ; }
61+ set disabled ( value : any ) {
62+ this . _disabled = coerceBooleanProperty ( value ) ;
63+ }
64+ private _disabled = false ;
65+
66+ /** Whether the user has interacted with step or not. */
67+ get interacted ( ) { return this . _interacted ; }
68+ set interacted ( value : any ) {
69+ this . _interacted = coerceBooleanProperty ( value ) ;
70+ }
71+ private _interacted = false ;
72+
5773 /** Label of the step. */
5874 @Input ( )
5975 label : string ;
@@ -84,7 +100,8 @@ export class CdkStepper {
84100 @Input ( )
85101 get selectedIndex ( ) { return this . _selectedIndex ; }
86102 set selectedIndex ( index : number ) {
87- if ( this . _selectedIndex != index ) {
103+ this . _steps . toArray ( ) [ this . _selectedIndex ] . interacted = true ;
104+ if ( this . _selectedIndex != index && ! this . _steps . toArray ( ) [ index ] . disabled ) {
88105 this . _emitStepperSelectionEvent ( index ) ;
89106 this . _focusStep ( this . _selectedIndex ) ;
90107 }
@@ -153,7 +170,7 @@ export class CdkStepper {
153170 break ;
154171 case SPACE :
155172 case ENTER :
156- this . _emitStepperSelectionEvent ( this . _focusIndex ) ;
173+ this . selectedIndex = this . _focusIndex ;
157174 break ;
158175 default :
159176 // Return to avoid calling preventDefault on keys that are not explicitly handled.
0 commit comments