Reset select-selector to undefined when cleared (#20821)

This commit is contained in:
karwosts 2024-05-18 08:28:59 -07:00 committed by GitHub
parent 111816f08a
commit 914dbc1e28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -278,6 +278,14 @@ export class HaSelectSelector extends LitElement {
private _valueChanged(ev) { private _valueChanged(ev) {
ev.stopPropagation(); ev.stopPropagation();
if (ev.detail?.index === -1 && this.value !== undefined) {
fireEvent(this, "value-changed", {
value: undefined,
});
return;
}
const value = ev.detail?.value || ev.target.value; const value = ev.detail?.value || ev.target.value;
if (this.disabled || value === undefined || value === (this.value ?? "")) { if (this.disabled || value === undefined || value === (this.value ?? "")) {
return; return;