@@ -28,23 +28,27 @@ 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 ,
36
+ HasTabIndex ,
35
37
MATERIAL_COMPATIBILITY_MODE ,
36
38
MdLine ,
37
39
MdLineSetter ,
38
40
mixinDisabled ,
39
41
mixinDisableRipple ,
42
+ mixinTabIndex ,
40
43
} from '@angular/material/core' ;
41
44
import { merge } from 'rxjs/observable/merge' ;
42
45
import { Subscription } from 'rxjs/Subscription' ;
43
46
44
47
45
48
/** @docs -private */
46
49
export class MdSelectionListBase { }
47
- export const _MdSelectionListMixinBase = mixinDisableRipple ( mixinDisabled ( MdSelectionListBase ) ) ;
50
+ export const _MdSelectionListMixinBase =
51
+ mixinTabIndex ( mixinDisableRipple ( mixinDisabled ( MdSelectionListBase ) ) ) ;
48
52
49
53
/** @docs -private */
50
54
export class MdListOptionBase { }
@@ -189,10 +193,10 @@ export class MdListOption extends _MdListOptionMixinBase
189
193
@Component ( {
190
194
moduleId : module . id ,
191
195
selector : 'md-selection-list, mat-selection-list' ,
192
- inputs : [ 'disabled' , 'disableRipple' ] ,
196
+ inputs : [ 'disabled' , 'disableRipple' , 'tabIndex' ] ,
193
197
host : {
194
198
'role' : 'listbox' ,
195
- '[attr.tabindex ]' : '_tabIndex ' ,
199
+ '[tabIndex ]' : 'tabIndex ' ,
196
200
'class' : 'mat-selection-list' ,
197
201
'(focus)' : 'focus()' ,
198
202
'(keydown)' : '_keydown($event)' ,
@@ -203,11 +207,8 @@ export class MdListOption extends _MdListOptionMixinBase
203
207
preserveWhitespaces : false ,
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