9
9
import { coerceBooleanProperty } from '@angular/cdk/coercion' ;
10
10
import {
11
11
AfterViewInit ,
12
+ Attribute ,
12
13
ChangeDetectionStrategy ,
13
14
ChangeDetectorRef ,
14
15
Component ,
@@ -27,10 +28,12 @@ import {
27
28
CanColor ,
28
29
CanDisable ,
29
30
CanDisableRipple ,
31
+ HasTabIndex ,
30
32
MatRipple ,
31
33
mixinColor ,
32
34
mixinDisabled ,
33
35
mixinDisableRipple ,
36
+ mixinTabIndex ,
34
37
RippleRef ,
35
38
} from '@angular/material/core' ;
36
39
import { FocusMonitor , FocusOrigin } from '@angular/cdk/a11y' ;
@@ -79,7 +82,7 @@ export class MatCheckboxBase {
79
82
constructor ( public _renderer : Renderer2 , public _elementRef : ElementRef ) { }
80
83
}
81
84
export const _MatCheckboxMixinBase =
82
- mixinColor ( mixinDisableRipple ( mixinDisabled ( MatCheckboxBase ) ) , 'accent' ) ;
85
+ mixinTabIndex ( mixinColor ( mixinDisableRipple ( mixinDisabled ( MatCheckboxBase ) ) , 'accent' ) ) ;
83
86
84
87
85
88
/**
@@ -104,13 +107,13 @@ export const _MatCheckboxMixinBase =
104
107
'[class.mat-checkbox-label-before]' : 'labelPosition == "before"' ,
105
108
} ,
106
109
providers : [ MAT_CHECKBOX_CONTROL_VALUE_ACCESSOR ] ,
107
- inputs : [ 'disabled' , 'disableRipple' , 'color' ] ,
110
+ inputs : [ 'disabled' , 'disableRipple' , 'color' , 'tabIndex' ] ,
108
111
encapsulation : ViewEncapsulation . None ,
109
112
preserveWhitespaces : false ,
110
113
changeDetection : ChangeDetectionStrategy . OnPush
111
114
} )
112
115
export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAccessor ,
113
- AfterViewInit , OnDestroy , CanColor , CanDisable , CanDisableRipple {
116
+ AfterViewInit , OnDestroy , CanColor , CanDisable , HasTabIndex , CanDisableRipple {
114
117
115
118
/**
116
119
* Attached to the aria-label attribute of the host element. In most cases, arial-labelledby will
@@ -156,9 +159,6 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
156
159
/** Whether the label should appear after or before the checkbox. Defaults to 'after' */
157
160
@Input ( ) labelPosition : 'before' | 'after' = 'after' ;
158
161
159
- /** Tabindex value that is passed to the underlying input element. */
160
- @Input ( ) tabIndex : number = 0 ;
161
-
162
162
/** Name value will be applied to the input element if present */
163
163
@Input ( ) name : string | null = null ;
164
164
@@ -199,8 +199,11 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
199
199
constructor ( renderer : Renderer2 ,
200
200
elementRef : ElementRef ,
201
201
private _changeDetectorRef : ChangeDetectorRef ,
202
- private _focusMonitor : FocusMonitor ) {
202
+ private _focusMonitor : FocusMonitor ,
203
+ @Attribute ( 'tabindex' ) tabIndex : string ) {
203
204
super ( renderer , elementRef ) ;
205
+
206
+ this . tabIndex = parseInt ( tabIndex ) || 0 ;
204
207
}
205
208
206
209
ngAfterViewInit ( ) {
0 commit comments