Skip to content

Commit 63da9e3

Browse files
authored
fix(material-experimental/mdc-list): fix infinite loop on init (#19930)
The MDC-based list was throwing an error on init due to an infinite loop caused by some incorrect syntax. Also gets rid of an unnecessary private method.
1 parent 5725e2b commit 63da9e3

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,20 +199,17 @@ export abstract class MatInteractiveListBase extends MatListBase
199199
}
200200

201201
private _initItems() {
202-
this._subscriptions.add(
203-
this._items.changes.pipe(startWith(null))
204-
.subscribe(() => this._itemsArr = this._items.toArray()));
205-
for (let i = 0; this._itemsArr.length; i++) {
202+
this._subscriptions.add(this._items.changes.pipe(startWith(null)).subscribe(() => {
203+
this._itemsArr = this._items.toArray();
204+
}));
205+
206+
for (let i = 0; i < this._itemsArr.length; i++) {
206207
this._itemsArr[i]._initDefaultTabIndex(i === 0 ? 0 : -1);
207208
}
208209
}
209210

210-
private _itemAtIndex(index: number): MatListItemBase {
211-
return this._itemsArr[index];
212-
}
213-
214211
private _elementAtIndex(index: number): HTMLElement {
215-
return this._itemAtIndex(index)._elementRef.nativeElement;
212+
return this._itemsArr[index]._elementRef.nativeElement;
216213
}
217214

218215
private _indexForElement(element: Element | null) {

0 commit comments

Comments
 (0)