@@ -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 { }
@@ -190,10 +194,10 @@ export class MdListOption extends _MdListOptionMixinBase
190
194
@Component ( {
191
195
moduleId : module . id ,
192
196
selector : 'md-selection-list, mat-selection-list' ,
193
- inputs : [ 'disabled' , 'disableRipple' ] ,
197
+ inputs : [ 'disabled' , 'disableRipple' , 'tabIndex' ] ,
194
198
host : {
195
199
'role' : 'listbox' ,
196
- '[attr.tabindex ]' : '_tabIndex ' ,
200
+ '[tabIndex ]' : 'tabIndex ' ,
197
201
'class' : 'mat-selection-list' ,
198
202
'(focus)' : 'focus()' ,
199
203
'(keydown)' : '_keydown($event)' ,
@@ -203,11 +207,8 @@ export class MdListOption extends _MdListOptionMixinBase
203
207
encapsulation : ViewEncapsulation . None ,
204
208
changeDetection : ChangeDetectionStrategy . OnPush
205
209
} )
206
- export class MdSelectionList extends _MdSelectionListMixinBase
207
- implements FocusableOption , CanDisable , CanDisableRipple , AfterContentInit , OnDestroy {
208
-
209
- /** Tab index for the selection-list. */
210
- _tabIndex = 0 ;
210
+ export class MdSelectionList extends _MdSelectionListMixinBase implements FocusableOption ,
211
+ CanDisable , CanDisableRipple , HasTabIndex , AfterContentInit , OnDestroy {
211
212
212
213
/** Subscription to all list options' onFocus events */
213
214
private _optionFocusSubscription = Subscription . EMPTY ;
@@ -224,17 +225,15 @@ export class MdSelectionList extends _MdSelectionListMixinBase
224
225
/** The currently selected options. */
225
226
selectedOptions : SelectionModel < MdListOption > = new SelectionModel < MdListOption > ( true ) ;
226
227
227
- constructor ( private _element : ElementRef ) {
228
+ constructor ( private _element : ElementRef , @ Attribute ( 'tabindex' ) tabIndex : string ) {
228
229
super ( ) ;
230
+
231
+ this . tabIndex = parseInt ( tabIndex ) || 0 ;
229
232
}
230
233
231
234
ngAfterContentInit ( ) : void {
232
235
this . _keyManager = new FocusKeyManager < MdListOption > ( this . options ) . withWrap ( ) ;
233
236
234
- if ( this . disabled ) {
235
- this . _tabIndex = - 1 ;
236
- }
237
-
238
237
this . _optionFocusSubscription = this . _onFocusSubscription ( ) ;
239
238
this . _optionDestroyStream = this . _onDestroySubscription ( ) ;
240
239
}
0 commit comments