@@ -28,23 +28,27 @@ import {
2828 QueryList ,
2929 Renderer2 ,
3030 ViewEncapsulation ,
31+ Attribute ,
3132} from '@angular/core' ;
3233import {
3334 CanDisable ,
3435 CanDisableRipple ,
36+ HasTabIndex ,
3537 MATERIAL_COMPATIBILITY_MODE ,
3638 MdLine ,
3739 MdLineSetter ,
3840 mixinDisabled ,
3941 mixinDisableRipple ,
42+ mixinTabIndex ,
4043} from '@angular/material/core' ;
4144import { merge } from 'rxjs/observable/merge' ;
4245import { Subscription } from 'rxjs/Subscription' ;
4346
4447
4548/** @docs -private */
4649export class MdSelectionListBase { }
47- export const _MdSelectionListMixinBase = mixinDisableRipple ( mixinDisabled ( MdSelectionListBase ) ) ;
50+ export const _MdSelectionListMixinBase =
51+ mixinTabIndex ( mixinDisableRipple ( mixinDisabled ( MdSelectionListBase ) ) ) ;
4852
4953/** @docs -private */
5054export class MdListOptionBase { }
@@ -189,10 +193,10 @@ export class MdListOption extends _MdListOptionMixinBase
189193@Component ( {
190194 moduleId : module . id ,
191195 selector : 'md-selection-list, mat-selection-list' ,
192- inputs : [ 'disabled' , 'disableRipple' ] ,
196+ inputs : [ 'disabled' , 'disableRipple' , 'tabIndex' ] ,
193197 host : {
194198 'role' : 'listbox' ,
195- '[attr.tabindex ]' : '_tabIndex ' ,
199+ '[tabIndex ]' : 'tabIndex ' ,
196200 'class' : 'mat-selection-list' ,
197201 '(focus)' : 'focus()' ,
198202 '(keydown)' : '_keydown($event)' ,
@@ -203,11 +207,8 @@ export class MdListOption extends _MdListOptionMixinBase
203207 preserveWhitespaces : false ,
204208 changeDetection : ChangeDetectionStrategy . OnPush
205209} )
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 {
211212
212213 /** Subscription to all list options' onFocus events */
213214 private _optionFocusSubscription = Subscription . EMPTY ;
@@ -224,17 +225,15 @@ export class MdSelectionList extends _MdSelectionListMixinBase
224225 /** The currently selected options. */
225226 selectedOptions : SelectionModel < MdListOption > = new SelectionModel < MdListOption > ( true ) ;
226227
227- constructor ( private _element : ElementRef ) {
228+ constructor ( private _element : ElementRef , @ Attribute ( 'tabindex' ) tabIndex : string ) {
228229 super ( ) ;
230+
231+ this . tabIndex = parseInt ( tabIndex ) || 0 ;
229232 }
230233
231234 ngAfterContentInit ( ) : void {
232235 this . _keyManager = new FocusKeyManager < MdListOption > ( this . options ) . withWrap ( ) ;
233236
234- if ( this . disabled ) {
235- this . _tabIndex = - 1 ;
236- }
237-
238237 this . _optionFocusSubscription = this . _onFocusSubscription ( ) ;
239238 this . _optionDestroyStream = this . _onDestroySubscription ( ) ;
240239 }
0 commit comments