@@ -26,15 +26,18 @@ import {
26
26
QueryList ,
27
27
Renderer2 ,
28
28
ViewEncapsulation ,
29
+ Attribute ,
29
30
} from '@angular/core' ;
30
31
import {
31
32
CanDisable ,
32
33
CanDisableRipple ,
34
+ HasTabIndex ,
33
35
MATERIAL_COMPATIBILITY_MODE ,
34
36
MdLine ,
35
37
MdLineSetter ,
36
38
mixinDisabled ,
37
39
mixinDisableRipple ,
40
+ mixinTabIndex ,
38
41
RxChain ,
39
42
SPACE ,
40
43
startWith ,
@@ -46,7 +49,8 @@ import {Subscription} from 'rxjs/Subscription';
46
49
47
50
/** @docs -private */
48
51
export class MdSelectionListBase { }
49
- export const _MdSelectionListMixinBase = mixinDisableRipple ( mixinDisabled ( MdSelectionListBase ) ) ;
52
+ export const _MdSelectionListMixinBase =
53
+ mixinTabIndex ( mixinDisableRipple ( mixinDisabled ( MdSelectionListBase ) ) ) ;
50
54
51
55
/** @docs -private */
52
56
export class MdListOptionBase { }
@@ -191,10 +195,10 @@ export class MdListOption extends _MdListOptionMixinBase
191
195
@Component ( {
192
196
moduleId : module . id ,
193
197
selector : 'md-selection-list, mat-selection-list' ,
194
- inputs : [ 'disabled' , 'disableRipple' ] ,
198
+ inputs : [ 'disabled' , 'disableRipple' , 'tabIndex' ] ,
195
199
host : {
196
200
'role' : 'listbox' ,
197
- '[attr.tabindex ]' : '_tabIndex ' ,
201
+ '[tabIndex ]' : 'tabIndex ' ,
198
202
'class' : 'mat-selection-list' ,
199
203
'(focus)' : 'focus()' ,
200
204
'(keydown)' : '_keydown($event)' ,
@@ -205,11 +209,8 @@ export class MdListOption extends _MdListOptionMixinBase
205
209
preserveWhitespaces : false ,
206
210
changeDetection : ChangeDetectionStrategy . OnPush
207
211
} )
208
- export class MdSelectionList extends _MdSelectionListMixinBase
209
- implements FocusableOption , CanDisable , CanDisableRipple , AfterContentInit , OnDestroy {
210
-
211
- /** Tab index for the selection-list. */
212
- _tabIndex = 0 ;
212
+ export class MdSelectionList extends _MdSelectionListMixinBase implements FocusableOption ,
213
+ CanDisable , CanDisableRipple , HasTabIndex , AfterContentInit , OnDestroy {
213
214
214
215
/** Subscription to all list options' onFocus events */
215
216
private _optionFocusSubscription = Subscription . EMPTY ;
@@ -226,17 +227,15 @@ export class MdSelectionList extends _MdSelectionListMixinBase
226
227
/** The currently selected options. */
227
228
selectedOptions : SelectionModel < MdListOption > = new SelectionModel < MdListOption > ( true ) ;
228
229
229
- constructor ( private _element : ElementRef ) {
230
+ constructor ( private _element : ElementRef , @ Attribute ( 'tabindex' ) tabIndex : string ) {
230
231
super ( ) ;
232
+
233
+ this . tabIndex = parseInt ( tabIndex ) || 0 ;
231
234
}
232
235
233
236
ngAfterContentInit ( ) : void {
234
237
this . _keyManager = new FocusKeyManager < MdListOption > ( this . options ) . withWrap ( ) ;
235
238
236
- if ( this . disabled ) {
237
- this . _tabIndex = - 1 ;
238
- }
239
-
240
239
this . _optionFocusSubscription = this . _onFocusSubscription ( ) ;
241
240
this . _optionDestroyStream = this . _onDestroySubscription ( ) ;
242
241
}
0 commit comments