Skip to content

Commit 0741b56

Browse files
committed
fix tabIndex initialization
1 parent 6c026d2 commit 0741b56

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/material-experimental/mdc-list/list-base.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ function toggleClass(el: Element, className: string, on: boolean) {
3737
@Directive()
3838
/** @docs-private */
3939
export abstract class MatListItemBase implements AfterContentInit, OnDestroy, RippleTarget {
40-
@HostBinding('tabindex')
41-
_tabIndex = -1;
42-
4340
lines: QueryList<ElementRef<Element>>;
4441

4542
rippleConfig: RippleConfig = {};
@@ -180,15 +177,14 @@ export abstract class MatInteractiveListBase extends MatListBase
180177
}
181178

182179
ngAfterViewInit() {
183-
this._foundation.init();
184-
const first = this._items.first;
185-
if (first) {
186-
first._elementRef.nativeElement.tabIndex = 0;
187-
}
188-
this._foundation.layout();
189180
this._subscriptions.add(
190181
this._items.changes.pipe(startWith(null))
191182
.subscribe(() => this._itemsArr = this._items.toArray()));
183+
this._foundation.init();
184+
for (let i = 0; this._items.length; i++) {
185+
this._elementAtIndex(i).tabIndex = i === 0 ? 0 : -1;
186+
}
187+
this._foundation.layout();
192188
}
193189

194190
ngOnDestroy() {

0 commit comments

Comments
 (0)