99import { coerceBooleanProperty } from '@angular/cdk/coercion' ;
1010import {
1111 AfterContentInit ,
12+ Attribute ,
1213 ChangeDetectionStrategy ,
1314 ChangeDetectorRef ,
1415 Component ,
@@ -39,6 +40,8 @@ export class MatDatepickerToggleIcon {}
3940 styleUrls : [ 'datepicker-toggle.css' ] ,
4041 host : {
4142 'class' : 'mat-datepicker-toggle' ,
43+ // Clear out the native tabindex here since we forward it to the underlying button
44+ '[attr.tabindex]' : 'null' ,
4245 '[class.mat-datepicker-toggle-active]' : 'datepicker && datepicker.opened' ,
4346 '[class.mat-accent]' : 'datepicker && datepicker.color === "accent"' ,
4447 '[class.mat-warn]' : 'datepicker && datepicker.color === "warn"' ,
@@ -53,6 +56,9 @@ export class MatDatepickerToggle<D> implements AfterContentInit, OnChanges, OnDe
5356 /** Datepicker instance that the button will toggle. */
5457 @Input ( 'for' ) datepicker : MatDatepicker < D > ;
5558
59+ /** Tabindex for the toggle. */
60+ @Input ( ) tabIndex : number | null ;
61+
5662 /** Whether the toggle button is disabled. */
5763 @Input ( )
5864 get disabled ( ) : boolean {
@@ -66,7 +72,14 @@ export class MatDatepickerToggle<D> implements AfterContentInit, OnChanges, OnDe
6672 /** Custom icon set by the consumer. */
6773 @ContentChild ( MatDatepickerToggleIcon ) _customIcon : MatDatepickerToggleIcon ;
6874
69- constructor ( public _intl : MatDatepickerIntl , private _changeDetectorRef : ChangeDetectorRef ) { }
75+ constructor (
76+ public _intl : MatDatepickerIntl ,
77+ private _changeDetectorRef : ChangeDetectorRef ,
78+ @Attribute ( 'tabindex' ) defaultTabIndex : string ) {
79+
80+ const parsedTabIndex = Number ( defaultTabIndex ) ;
81+ this . tabIndex = ( parsedTabIndex || parsedTabIndex === 0 ) ? parsedTabIndex : null ;
82+ }
7083
7184 ngOnChanges ( changes : SimpleChanges ) {
7285 if ( changes . datepicker ) {
0 commit comments