@@ -24,6 +24,7 @@ import {
24
24
} from '@angular/core' ;
25
25
import { LEFT_ARROW , RIGHT_ARROW , ENTER , SPACE } from '@angular/cdk/keyboard' ;
26
26
import { CdkStepLabel } from './step-label' ;
27
+ import { coerceBooleanProperty } from '@angular/cdk/coercion' ;
27
28
28
29
/** Used to generate unique ID for each stepper component. */
29
30
let nextId = 0 ;
@@ -45,7 +46,7 @@ export class CdkStepperSelectionEvent {
45
46
46
47
@Component ( {
47
48
selector : 'cdk-step' ,
48
- templateUrl : 'step.html' ,
49
+ templateUrl : 'step.html'
49
50
} )
50
51
export class CdkStep {
51
52
/** Template for step label if it exists. */
@@ -54,6 +55,21 @@ export class CdkStep {
54
55
/** Template for step content. */
55
56
@ViewChild ( TemplateRef ) content : TemplateRef < any > ;
56
57
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
+
57
73
/** Label of the step. */
58
74
@Input ( )
59
75
label : string ;
@@ -84,7 +100,8 @@ export class CdkStepper {
84
100
@Input ( )
85
101
get selectedIndex ( ) { return this . _selectedIndex ; }
86
102
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 ) {
88
105
this . _emitStepperSelectionEvent ( index ) ;
89
106
this . _focusStep ( this . _selectedIndex ) ;
90
107
}
@@ -153,7 +170,7 @@ export class CdkStepper {
153
170
break ;
154
171
case SPACE :
155
172
case ENTER :
156
- this . _emitStepperSelectionEvent ( this . _focusIndex ) ;
173
+ this . selectedIndex = this . _focusIndex ;
157
174
break ;
158
175
default :
159
176
// Return to avoid calling preventDefault on keys that are not explicitly handled.
0 commit comments