@@ -10,6 +10,7 @@ import {FocusableOption, FocusMonitor, FocusOrigin} from '@angular/cdk/a11y';
1010import { ENTER , hasModifierKey , SPACE } from '@angular/cdk/keycodes' ;
1111import {
1212 AfterViewInit ,
13+ Attribute ,
1314 ChangeDetectionStrategy ,
1415 ChangeDetectorRef ,
1516 Component ,
@@ -23,6 +24,7 @@ import {
2324 ViewEncapsulation ,
2425} from '@angular/core' ;
2526import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations' ;
27+ import { HasTabIndex , HasTabIndexCtor , mixinTabIndex } from '@angular/material/core' ;
2628import { EMPTY , merge , Subscription } from 'rxjs' ;
2729import { filter } from 'rxjs/operators' ;
2830import { MatAccordionTogglePosition } from './accordion-base' ;
@@ -34,6 +36,15 @@ import {
3436} from './expansion-panel' ;
3537
3638
39+ // Boilerplate for applying mixins to MatExpansionPanelHeader.
40+ /** @docs -private */
41+ abstract class MatExpansionPanelHeaderBase {
42+ abstract readonly disabled : boolean ;
43+ }
44+ const _MatExpansionPanelHeaderMixinBase :
45+ HasTabIndexCtor &
46+ typeof MatExpansionPanelHeaderBase = mixinTabIndex ( MatExpansionPanelHeaderBase ) ;
47+
3748/**
3849 * Header element of a `<mat-expansion-panel>`.
3950 */
@@ -43,14 +54,15 @@ import {
4354 templateUrl : 'expansion-panel-header.html' ,
4455 encapsulation : ViewEncapsulation . None ,
4556 changeDetection : ChangeDetectionStrategy . OnPush ,
57+ inputs : [ 'tabIndex' ] ,
4658 animations : [
4759 matExpansionAnimations . indicatorRotate ,
4860 ] ,
4961 host : {
5062 'class' : 'mat-expansion-panel-header mat-focus-indicator' ,
5163 'role' : 'button' ,
5264 '[attr.id]' : 'panel._headerId' ,
53- '[attr.tabindex]' : 'disabled ? -1 : 0 ' ,
65+ '[attr.tabindex]' : 'tabIndex ' ,
5466 '[attr.aria-controls]' : '_getPanelId()' ,
5567 '[attr.aria-expanded]' : '_isExpanded()' ,
5668 '[attr.aria-disabled]' : 'panel.disabled' ,
@@ -63,7 +75,8 @@ import {
6375 '(keydown)' : '_keydown($event)' ,
6476 } ,
6577} )
66- export class MatExpansionPanelHeader implements AfterViewInit , OnDestroy , FocusableOption {
78+ export class MatExpansionPanelHeader extends _MatExpansionPanelHeaderMixinBase implements
79+ AfterViewInit , OnDestroy , FocusableOption , HasTabIndex {
6780 private _parentChangeSubscription = Subscription . EMPTY ;
6881
6982 constructor (
@@ -73,11 +86,14 @@ export class MatExpansionPanelHeader implements AfterViewInit, OnDestroy, Focusa
7386 private _changeDetectorRef : ChangeDetectorRef ,
7487 @Inject ( MAT_EXPANSION_PANEL_DEFAULT_OPTIONS ) @Optional ( )
7588 defaultOptions ?: MatExpansionPanelDefaultOptions ,
76- @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) public _animationMode ?: string ) {
89+ @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) public _animationMode ?: string ,
90+ @Attribute ( 'tabindex' ) tabIndex ?: string ) {
91+ super ( ) ;
7792 const accordionHideToggleChange = panel . accordion ?
7893 panel . accordion . _stateChanges . pipe (
7994 filter ( changes => ! ! ( changes [ 'hideToggle' ] || changes [ 'togglePosition' ] ) ) ) :
8095 EMPTY ;
96+ this . tabIndex = parseInt ( tabIndex || '' ) || 0 ;
8197
8298 // Since the toggle state depends on an @Input on the panel, we
8399 // need to subscribe and trigger change detection manually.
0 commit comments