Fix entity picker delete button (#20875)

This commit is contained in:
karwosts 2024-05-26 06:29:57 -07:00 committed by GitHub
parent f59ed0a72b
commit 6ccbeb8a75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -405,9 +405,9 @@ export class HaEntityPicker extends LitElement {
this._opened = ev.detail.value; this._opened = ev.detail.value;
} }
private _valueChanged(ev: ValueChangedEvent<string>) { private _valueChanged(ev: ValueChangedEvent<string | undefined>) {
ev.stopPropagation(); ev.stopPropagation();
const newValue = ev.detail.value.trim(); const newValue = ev.detail.value?.trim();
if (newValue && newValue.startsWith(CREATE_ID)) { if (newValue && newValue.startsWith(CREATE_ID)) {
const domain = newValue.substring(CREATE_ID.length); const domain = newValue.substring(CREATE_ID.length);
@ -433,7 +433,7 @@ export class HaEntityPicker extends LitElement {
: this._states; : this._states;
} }
private _setValue(value: string) { private _setValue(value: string | undefined) {
this.value = value; this.value = value;
setTimeout(() => { setTimeout(() => {
fireEvent(this, "value-changed", { value }); fireEvent(this, "value-changed", { value });