@@ -10,6 +10,7 @@ import {FocusableOption, FocusMonitor, FocusOrigin} from '@angular/cdk/a11y';
10
10
import { ENTER , hasModifierKey , SPACE } from '@angular/cdk/keycodes' ;
11
11
import {
12
12
AfterViewInit ,
13
+ Attribute ,
13
14
ChangeDetectionStrategy ,
14
15
ChangeDetectorRef ,
15
16
Component ,
@@ -23,6 +24,7 @@ import {
23
24
ViewEncapsulation ,
24
25
} from '@angular/core' ;
25
26
import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations' ;
27
+ import { HasTabIndex , HasTabIndexCtor , mixinTabIndex } from '@angular/material/core' ;
26
28
import { EMPTY , merge , Subscription } from 'rxjs' ;
27
29
import { filter } from 'rxjs/operators' ;
28
30
import { MatAccordionTogglePosition } from './accordion-base' ;
@@ -34,6 +36,15 @@ import {
34
36
} from './expansion-panel' ;
35
37
36
38
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
+
37
48
/**
38
49
* Header element of a `<mat-expansion-panel>`.
39
50
*/
@@ -43,14 +54,15 @@ import {
43
54
templateUrl : 'expansion-panel-header.html' ,
44
55
encapsulation : ViewEncapsulation . None ,
45
56
changeDetection : ChangeDetectionStrategy . OnPush ,
57
+ inputs : [ 'tabIndex' ] ,
46
58
animations : [
47
59
matExpansionAnimations . indicatorRotate ,
48
60
] ,
49
61
host : {
50
62
'class' : 'mat-expansion-panel-header mat-focus-indicator' ,
51
63
'role' : 'button' ,
52
64
'[attr.id]' : 'panel._headerId' ,
53
- '[attr.tabindex]' : 'disabled ? -1 : 0 ' ,
65
+ '[attr.tabindex]' : 'tabIndex ' ,
54
66
'[attr.aria-controls]' : '_getPanelId()' ,
55
67
'[attr.aria-expanded]' : '_isExpanded()' ,
56
68
'[attr.aria-disabled]' : 'panel.disabled' ,
@@ -63,7 +75,8 @@ import {
63
75
'(keydown)' : '_keydown($event)' ,
64
76
} ,
65
77
} )
66
- export class MatExpansionPanelHeader implements AfterViewInit , OnDestroy , FocusableOption {
78
+ export class MatExpansionPanelHeader extends _MatExpansionPanelHeaderMixinBase implements
79
+ AfterViewInit , OnDestroy , FocusableOption , HasTabIndex {
67
80
private _parentChangeSubscription = Subscription . EMPTY ;
68
81
69
82
constructor (
@@ -73,11 +86,14 @@ export class MatExpansionPanelHeader implements AfterViewInit, OnDestroy, Focusa
73
86
private _changeDetectorRef : ChangeDetectorRef ,
74
87
@Inject ( MAT_EXPANSION_PANEL_DEFAULT_OPTIONS ) @Optional ( )
75
88
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 ( ) ;
77
92
const accordionHideToggleChange = panel . accordion ?
78
93
panel . accordion . _stateChanges . pipe (
79
94
filter ( changes => ! ! ( changes [ 'hideToggle' ] || changes [ 'togglePosition' ] ) ) ) :
80
95
EMPTY ;
96
+ this . tabIndex = parseInt ( tabIndex || '' ) || 0 ;
81
97
82
98
// Since the toggle state depends on an @Input on the panel, we
83
99
// need to subscribe and trigger change detection manually.
0 commit comments