From 9a9b2e39000d38a5456eac609cff513d4b67d94b Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Wed, 30 Oct 2024 04:34:14 -0700 Subject: [PATCH] Don't push a duplicate entry to select selector when filtering (#22578) --- src/components/ha-selector/ha-selector-select.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/ha-selector/ha-selector-select.ts b/src/components/ha-selector/ha-selector-select.ts index 82ebf8bc1fe0..b32c02c6fd31 100644 --- a/src/components/ha-selector/ha-selector-select.ts +++ b/src/components/ha-selector/ha-selector-select.ts @@ -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;