@@ -28,22 +28,26 @@ import {
2828 QueryList ,
2929 Renderer2 ,
3030 ViewEncapsulation ,
31+ Attribute ,
3132} from '@angular/core' ;
3233import {
3334 CanDisable ,
3435 CanDisableRipple ,
3536 MatLine ,
3637 MatLineSetter ,
38+ HasTabIndex ,
3739 mixinDisabled ,
3840 mixinDisableRipple ,
41+ mixinTabIndex ,
3942} from '@angular/material/core' ;
4043import { merge } from 'rxjs/observable/merge' ;
4144import { Subscription } from 'rxjs/Subscription' ;
4245
4346
4447/** @docs -private */
4548export class MatSelectionListBase { }
46- export const _MatSelectionListMixinBase = mixinDisableRipple ( mixinDisabled ( MatSelectionListBase ) ) ;
49+ export const _MatSelectionListMixinBase =
50+ mixinTabIndex ( mixinDisableRipple ( mixinDisabled ( MatSelectionListBase ) ) ) ;
4751
4852/** @docs -private */
4953export class MatListOptionBase { }
@@ -187,10 +191,10 @@ export class MatListOption extends _MatListOptionMixinBase
187191@Component ( {
188192 moduleId : module . id ,
189193 selector : 'mat-selection-list' ,
190- inputs : [ 'disabled' , 'disableRipple' ] ,
194+ inputs : [ 'disabled' , 'disableRipple' , 'tabIndex' ] ,
191195 host : {
192196 'role' : 'listbox' ,
193- '[attr.tabindex ]' : '_tabIndex ' ,
197+ '[tabIndex ]' : 'tabIndex ' ,
194198 'class' : 'mat-selection-list' ,
195199 '(focus)' : 'focus()' ,
196200 '(keydown)' : '_keydown($event)' ,
@@ -201,11 +205,8 @@ export class MatListOption extends _MatListOptionMixinBase
201205 preserveWhitespaces : false ,
202206 changeDetection : ChangeDetectionStrategy . OnPush
203207} )
204- export class MatSelectionList extends _MatSelectionListMixinBase
205- implements FocusableOption , CanDisable , CanDisableRipple , AfterContentInit , OnDestroy {
206-
207- /** Tab index for the selection-list. */
208- _tabIndex = 0 ;
208+ export class MatSelectionList extends _MatSelectionListMixinBase implements FocusableOption ,
209+ CanDisable , CanDisableRipple , HasTabIndex , AfterContentInit , OnDestroy {
209210
210211 /** Subscription to all list options' onFocus events */
211212 private _optionFocusSubscription = Subscription . EMPTY ;
@@ -222,17 +223,15 @@ export class MatSelectionList extends _MatSelectionListMixinBase
222223 /** The currently selected options. */
223224 selectedOptions : SelectionModel < MatListOption > = new SelectionModel < MatListOption > ( true ) ;
224225
225- constructor ( private _element : ElementRef ) {
226+ constructor ( private _element : ElementRef , @ Attribute ( 'tabindex' ) tabIndex : string ) {
226227 super ( ) ;
228+
229+ this . tabIndex = parseInt ( tabIndex ) || 0 ;
227230 }
228231
229232 ngAfterContentInit ( ) : void {
230233 this . _keyManager = new FocusKeyManager < MatListOption > ( this . options ) . withWrap ( ) ;
231234
232- if ( this . disabled ) {
233- this . _tabIndex = - 1 ;
234- }
235-
236235 this . _optionFocusSubscription = this . _onFocusSubscription ( ) ;
237236 this . _optionDestroyStream = this . _onDestroySubscription ( ) ;
238237 }
0 commit comments