Skip to content

Commit

Permalink
Don't push a duplicate entry to select selector when filtering (#22578)
Browse files Browse the repository at this point in the history
  • Loading branch information
karwosts authored Oct 30, 2024
1 parent 830d8d2 commit 9a9b2e3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/ha-selector/ha-selector-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,13 @@ export class HaSelectSelector extends LitElement {
return label.toLowerCase().includes(this._filter?.toLowerCase());
});

if (this._filter && this.selector.select?.custom_value) {
filteredItems?.unshift({ label: this._filter, value: this._filter });
if (
this._filter &&
this.selector.select?.custom_value &&
filteredItems &&
!filteredItems.some((item) => (item.label || item.value) === this._filter)
) {
filteredItems.unshift({ label: this._filter, value: this._filter });
}

this.comboBox.filteredItems = filteredItems;
Expand Down

0 comments on commit 9a9b2e3

Please sign in to comment.