99import { coerceBooleanProperty } from '@angular/cdk/coercion' ;
1010import {
1111 AfterViewInit ,
12+ Attribute ,
1213 ChangeDetectionStrategy ,
1314 ChangeDetectorRef ,
1415 Component ,
@@ -27,10 +28,12 @@ import {
2728 CanColor ,
2829 CanDisable ,
2930 CanDisableRipple ,
31+ HasTabIndex ,
3032 MatRipple ,
3133 mixinColor ,
3234 mixinDisabled ,
3335 mixinDisableRipple ,
36+ mixinTabIndex ,
3437 RippleRef ,
3538} from '@angular/material/core' ;
3639import { FocusMonitor , FocusOrigin } from '@angular/cdk/a11y' ;
@@ -79,7 +82,7 @@ export class MatCheckboxBase {
7982 constructor ( public _renderer : Renderer2 , public _elementRef : ElementRef ) { }
8083}
8184export const _MatCheckboxMixinBase =
82- mixinColor ( mixinDisableRipple ( mixinDisabled ( MatCheckboxBase ) ) , 'accent' ) ;
85+ mixinTabIndex ( mixinColor ( mixinDisableRipple ( mixinDisabled ( MatCheckboxBase ) ) , 'accent' ) ) ;
8386
8487
8588/**
@@ -104,13 +107,13 @@ export const _MatCheckboxMixinBase =
104107 '[class.mat-checkbox-label-before]' : 'labelPosition == "before"' ,
105108 } ,
106109 providers : [ MAT_CHECKBOX_CONTROL_VALUE_ACCESSOR ] ,
107- inputs : [ 'disabled' , 'disableRipple' , 'color' ] ,
110+ inputs : [ 'disabled' , 'disableRipple' , 'color' , 'tabIndex' ] ,
108111 encapsulation : ViewEncapsulation . None ,
109112 preserveWhitespaces : false ,
110113 changeDetection : ChangeDetectionStrategy . OnPush
111114} )
112115export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAccessor ,
113- AfterViewInit , OnDestroy , CanColor , CanDisable , CanDisableRipple {
116+ AfterViewInit , OnDestroy , CanColor , CanDisable , HasTabIndex , CanDisableRipple {
114117
115118 /**
116119 * 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
156159 /** Whether the label should appear after or before the checkbox. Defaults to 'after' */
157160 @Input ( ) labelPosition : 'before' | 'after' = 'after' ;
158161
159- /** Tabindex value that is passed to the underlying input element. */
160- @Input ( ) tabIndex : number = 0 ;
161-
162162 /** Name value will be applied to the input element if present */
163163 @Input ( ) name : string | null = null ;
164164
@@ -199,8 +199,11 @@ export class MatCheckbox extends _MatCheckboxMixinBase implements ControlValueAc
199199 constructor ( renderer : Renderer2 ,
200200 elementRef : ElementRef ,
201201 private _changeDetectorRef : ChangeDetectorRef ,
202- private _focusMonitor : FocusMonitor ) {
202+ private _focusMonitor : FocusMonitor ,
203+ @Attribute ( 'tabindex' ) tabIndex : string ) {
203204 super ( renderer , elementRef ) ;
205+
206+ this . tabIndex = parseInt ( tabIndex ) || 0 ;
204207 }
205208
206209 ngAfterViewInit ( ) {
0 commit comments