@@ -28,22 +28,26 @@ import {
28
28
QueryList ,
29
29
Renderer2 ,
30
30
ViewEncapsulation ,
31
+ Attribute ,
31
32
} from '@angular/core' ;
32
33
import {
33
34
CanDisable ,
34
35
CanDisableRipple ,
35
36
MatLine ,
36
37
MatLineSetter ,
38
+ HasTabIndex ,
37
39
mixinDisabled ,
38
40
mixinDisableRipple ,
41
+ mixinTabIndex ,
39
42
} from '@angular/material/core' ;
40
43
import { merge } from 'rxjs/observable/merge' ;
41
44
import { Subscription } from 'rxjs/Subscription' ;
42
45
43
46
44
47
/** @docs -private */
45
48
export class MatSelectionListBase { }
46
- export const _MatSelectionListMixinBase = mixinDisableRipple ( mixinDisabled ( MatSelectionListBase ) ) ;
49
+ export const _MatSelectionListMixinBase =
50
+ mixinTabIndex ( mixinDisableRipple ( mixinDisabled ( MatSelectionListBase ) ) ) ;
47
51
48
52
/** @docs -private */
49
53
export class MatListOptionBase { }
@@ -187,10 +191,10 @@ export class MatListOption extends _MatListOptionMixinBase
187
191
@Component ( {
188
192
moduleId : module . id ,
189
193
selector : 'mat-selection-list' ,
190
- inputs : [ 'disabled' , 'disableRipple' ] ,
194
+ inputs : [ 'disabled' , 'disableRipple' , 'tabIndex' ] ,
191
195
host : {
192
196
'role' : 'listbox' ,
193
- '[attr.tabindex ]' : '_tabIndex ' ,
197
+ '[tabIndex ]' : 'tabIndex ' ,
194
198
'class' : 'mat-selection-list' ,
195
199
'(focus)' : 'focus()' ,
196
200
'(keydown)' : '_keydown($event)' ,
@@ -201,11 +205,8 @@ export class MatListOption extends _MatListOptionMixinBase
201
205
preserveWhitespaces : false ,
202
206
changeDetection : ChangeDetectionStrategy . OnPush
203
207
} )
204
- export class MatSelectionList extends _MatSelectionListMixinBase
205
- implements FocusableOption , CanDisable , CanDisableRipple , AfterContentInit , OnDestroy {
206
-
207
- /** Tab index for the selection-list. */
208
- _tabIndex = 0 ;
208
+ export class MatSelectionList extends _MatSelectionListMixinBase implements FocusableOption ,
209
+ CanDisable , CanDisableRipple , HasTabIndex , AfterContentInit , OnDestroy {
209
210
210
211
/** Subscription to all list options' onFocus events */
211
212
private _optionFocusSubscription = Subscription . EMPTY ;
@@ -222,17 +223,15 @@ export class MatSelectionList extends _MatSelectionListMixinBase
222
223
/** The currently selected options. */
223
224
selectedOptions : SelectionModel < MatListOption > = new SelectionModel < MatListOption > ( true ) ;
224
225
225
- constructor ( private _element : ElementRef ) {
226
+ constructor ( private _element : ElementRef , @ Attribute ( 'tabindex' ) tabIndex : string ) {
226
227
super ( ) ;
228
+
229
+ this . tabIndex = parseInt ( tabIndex ) || 0 ;
227
230
}
228
231
229
232
ngAfterContentInit ( ) : void {
230
233
this . _keyManager = new FocusKeyManager < MatListOption > ( this . options ) . withWrap ( ) ;
231
234
232
- if ( this . disabled ) {
233
- this . _tabIndex = - 1 ;
234
- }
235
-
236
235
this . _optionFocusSubscription = this . _onFocusSubscription ( ) ;
237
236
this . _optionDestroyStream = this . _onDestroySubscription ( ) ;
238
237
}
0 commit comments