Skip to content

Commit

Permalink
fix: resolve cannot read property of undefined when all list items ar…
Browse files Browse the repository at this point in the history
…e disabled (#2849)

Co-authored-by: Akshat Patel <[email protected]>
  • Loading branch information
Aru-Ku and Akshat55 authored Apr 19, 2024
1 parent ea07b2a commit 06ce722
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/dropdown/list/dropdown-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ export class DropdownList implements AbstractDropdownView, AfterViewInit, OnDest
}
}

return elemList[this.index].nativeElement;
return elemList[this.index]?.nativeElement;
}

/**
Expand Down Expand Up @@ -490,6 +490,7 @@ export class DropdownList implements AbstractDropdownView, AfterViewInit, OnDest
updateIndex() {
// initialize index on the first selected item or
// on the next non disabled item if no items are selected
// in case, if all items are disabled, the index value will remain same
const selected = this.getSelected();
if (selected.length) {
this.index = this.displayItems.indexOf(selected[0]);
Expand All @@ -513,7 +514,7 @@ export class DropdownList implements AbstractDropdownView, AfterViewInit, OnDest
event.preventDefault();
if (event.key === "ArrowDown") {
if (this.hasNextElement()) {
this.getNextElement().scrollIntoView({ block: "end" });
this.getNextElement()?.scrollIntoView({ block: "end" });
} else {
this.blurIntent.emit("bottom");
}
Expand Down

0 comments on commit 06ce722

Please sign in to comment.