Trim search inputs (#20825)

This commit is contained in:
Simon Lamon 2024-05-22 10:39:32 +02:00 committed by GitHub
parent ae9e1b724f
commit 2113cf5280
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 4 deletions

View File

@ -407,7 +407,7 @@ export class HaEntityPicker extends LitElement {
private _valueChanged(ev: ValueChangedEvent<string>) {
ev.stopPropagation();
const newValue = ev.detail.value;
const newValue = ev.detail.value.trim();
if (newValue && newValue.startsWith(CREATE_ID)) {
const domain = newValue.substring(CREATE_ID.length);
@ -427,7 +427,7 @@ export class HaEntityPicker extends LitElement {
private _filterChanged(ev: CustomEvent): void {
const target = ev.target as HaComboBox;
const filterString = ev.detail.value.toLowerCase();
const filterString = ev.detail.value.trim().toLowerCase();
target.filteredItems = filterString.length
? fuzzyFilterSort<HassEntityWithCachedName>(filterString, this._states)
: this._states;

View File

@ -79,7 +79,7 @@ class SearchInputOutlined extends LitElement {
}
private async _filterInputChanged(e) {
this._filterChanged(e.target.value);
this._filterChanged(e.target.value?.trim());
}
private async _clearSearch() {

View File

@ -67,7 +67,7 @@ class SearchInput extends LitElement {
}
private async _filterInputChanged(e) {
this._filterChanged(e.target.value);
this._filterChanged(e.target.value?.trim());
}
private async _clearSearch() {