Skip to content

Commit

Permalink
Don't push a duplicate entry to select selector when filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
karwosts committed Oct 28, 2024
1 parent 7a1838e commit 9baf78e
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 9baf78e

Please sign in to comment.