@@ -71,17 +71,6 @@ export abstract class MatListItemBase implements AfterContentInit, OnDestroy, Ri
71
71
this . _rippleRenderer . _removeTriggerEvents ( ) ;
72
72
}
73
73
74
- /**
75
- * Changes the tabindex of all button and anchor children of this item.
76
- *
77
- * This method is used by the `MatInteractiveBaseList` to implement the
78
- * `setTabIndexForListItemChildren` method on the `MDCListAdapter`
79
- */
80
- _setTabIndexForChildren ( value : number ) {
81
- this . _elementRef . nativeElement . querySelectorAll < HTMLElement > ( 'a, button' )
82
- . forEach ( el => el . tabIndex = value ) ;
83
- }
84
-
85
74
/**
86
75
* Subscribes to changes in `MatLine` content children and annotates them appropriately when they
87
76
* change.
@@ -148,13 +137,20 @@ export abstract class MatInteractiveListBase extends MatListBase
148
137
getAttributeForElementIndex : ( index , attr ) => this . _elementAtIndex ( index ) . getAttribute ( attr ) ,
149
138
setAttributeForElementIndex :
150
139
( index , attr , value ) => this . _elementAtIndex ( index ) . setAttribute ( attr , value ) ,
151
- setTabIndexForListItemChildren :
152
- ( index , value ) => this . _itemAtIndex ( index ) . _setTabIndexForChildren ( Number ( value ) ) ,
153
140
getFocusedElementIndex : ( ) => this . _indexForElement ( this . _document ?. activeElement ) ,
154
141
isFocusInsideList : ( ) => this . _element . nativeElement . contains ( this . _document ?. activeElement ) ,
155
142
isRootFocused : ( ) => this . _element . nativeElement === this . _document ?. activeElement ,
156
143
focusItemAtIndex : index => this . _elementAtIndex ( index ) . focus ( ) ,
157
144
145
+ // MDC uses this method to disable focusable children of list items. However, we believe that
146
+ // this is not an accessible pattern and should be avoided, therefore we intentionally do not
147
+ // implement this method. In addition, implementing this would require violating Angular
148
+ // Material's general principle of not having components modify DOM elements they do not own.
149
+ // A user who feels they really need this feature can simply listen to the `(focus)` and
150
+ // `(blur)` events on the list item and enable/disable focus on the children themselves as
151
+ // appropriate.
152
+ setTabIndexForListItemChildren : ( ) => { } ,
153
+
158
154
// The following methods have a dummy implementation in the base class because they are only
159
155
// applicable to certain types of lists. They should be implemented for the concrete classes
160
156
// where they are applicable.
@@ -185,13 +181,14 @@ export abstract class MatInteractiveListBase extends MatListBase
185
181
186
182
ngAfterViewInit ( ) {
187
183
this . _foundation . init ( ) ;
188
- const first = this . _itemAtIndex ( 0 ) ;
184
+ const first = this . _items . first ;
189
185
if ( first ) {
190
186
first . _elementRef . nativeElement . tabIndex = 0 ;
191
187
}
192
188
this . _foundation . layout ( ) ;
193
189
this . _subscriptions . add (
194
- this . _items . changes . subscribe ( ( ) => this . _itemsArr = this . _items . toArray ( ) ) ) ;
190
+ this . _items . changes . pipe ( startWith ( null ) )
191
+ . subscribe ( ( ) => this . _itemsArr = this . _items . toArray ( ) ) ) ;
195
192
}
196
193
197
194
ngOnDestroy ( ) {
0 commit comments