@@ -23,6 +23,7 @@ import {
2323 OnDestroy ,
2424 forwardRef ,
2525 Inject ,
26+ Attribute ,
2627} from '@angular/core' ;
2728import { coerceBooleanProperty , SelectionModel , MdLine , MdLineSetter } from '../core' ;
2829import { FocusKeyManager } from '../core/a11y/focus-key-manager' ;
@@ -34,11 +35,13 @@ import {RxChain, switchMap, startWith} from '../core/rxjs/index';
3435import { merge } from 'rxjs/observable/merge' ;
3536import { CanDisableRipple , mixinDisableRipple } from '../core/common-behaviors/disable-ripple' ;
3637import { MATERIAL_COMPATIBILITY_MODE } from '../core/compatibility/compatibility' ;
38+ import { mixinTabIndex , HasTabIndex } from '../core/common-behaviors/tabindex' ;
3739
3840
3941/** @docs -private */
4042export class MdSelectionListBase { }
41- export const _MdSelectionListMixinBase = mixinDisableRipple ( mixinDisabled ( MdSelectionListBase ) ) ;
43+ export const _MdSelectionListMixinBase =
44+ mixinTabIndex ( mixinDisableRipple ( mixinDisabled ( MdSelectionListBase ) ) ) ;
4245
4346/** @docs -private */
4447export class MdListOptionBase { }
@@ -182,10 +185,10 @@ export class MdListOption extends _MdListOptionMixinBase
182185@Component ( {
183186 moduleId : module . id ,
184187 selector : 'md-selection-list, mat-selection-list' ,
185- inputs : [ 'disabled' , 'disableRipple' ] ,
188+ inputs : [ 'disabled' , 'disableRipple' , 'tabIndex' ] ,
186189 host : {
187190 'role' : 'listbox' ,
188- '[attr.tabindex ]' : '_tabIndex ' ,
191+ '[tabIndex ]' : 'tabIndex ' ,
189192 'class' : 'mat-selection-list' ,
190193 '(focus)' : 'focus()' ,
191194 '(keydown)' : '_keydown($event)' ,
@@ -195,11 +198,8 @@ export class MdListOption extends _MdListOptionMixinBase
195198 encapsulation : ViewEncapsulation . None ,
196199 changeDetection : ChangeDetectionStrategy . OnPush
197200} )
198- export class MdSelectionList extends _MdSelectionListMixinBase
199- implements FocusableOption , CanDisable , CanDisableRipple , AfterContentInit , OnDestroy {
200-
201- /** Tab index for the selection-list. */
202- _tabIndex = 0 ;
201+ export class MdSelectionList extends _MdSelectionListMixinBase implements FocusableOption ,
202+ CanDisable , CanDisableRipple , HasTabIndex , AfterContentInit , OnDestroy {
203203
204204 /** Subscription to all list options' onFocus events */
205205 private _optionFocusSubscription = Subscription . EMPTY ;
@@ -216,17 +216,15 @@ export class MdSelectionList extends _MdSelectionListMixinBase
216216 /** The currently selected options. */
217217 selectedOptions : SelectionModel < MdListOption > = new SelectionModel < MdListOption > ( true ) ;
218218
219- constructor ( private _element : ElementRef ) {
219+ constructor ( private _element : ElementRef , @ Attribute ( 'tabindex' ) tabIndex : string ) {
220220 super ( ) ;
221+
222+ this . tabIndex = parseInt ( tabIndex ) || 0 ;
221223 }
222224
223225 ngAfterContentInit ( ) : void {
224226 this . _keyManager = new FocusKeyManager < MdListOption > ( this . options ) . withWrap ( ) ;
225227
226- if ( this . disabled ) {
227- this . _tabIndex = - 1 ;
228- }
229-
230228 this . _optionFocusSubscription = this . _onFocusSubscription ( ) ;
231229 this . _optionDestroyStream = this . _onDestroySubscription ( ) ;
232230 }
0 commit comments