1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-04-02 00:27:49 +01:00

Fix select-entity-row timeout (#30249)

* Fix select-entity-row timeout

* fix possible undefined exception
This commit is contained in:
karwosts
2026-03-23 07:07:50 -07:00
committed by GitHub
parent 984b50bac7
commit f03eee6cb2

View File

@@ -32,7 +32,23 @@ class HuiSelectEntityRow extends LitElement implements LovelaceRow {
}
protected shouldUpdate(changedProps: PropertyValues): boolean {
return hasConfigOrEntityChanged(this, changedProps);
return (
hasConfigOrEntityChanged(this, changedProps) ||
changedProps.has("_selectedEntityRow")
);
}
protected willUpdate(changedProps: PropertyValues): void {
super.willUpdate(changedProps);
if (
this.hass &&
this._config &&
changedProps.get("hass") &&
this.hass.states[this._config.entity] !==
changedProps.get("hass").states[this._config.entity]
) {
this._selectedEntityRow = undefined;
}
}
protected render() {
@@ -104,6 +120,8 @@ class HuiSelectEntityRow extends LitElement implements LovelaceRow {
forwardHaptic(this, "light");
this._selectedEntityRow = option;
setSelectOption(this.hass!, stateObj.entity_id, option)
.catch((_err) => {
// silently swallow exception
@@ -112,7 +130,7 @@ class HuiSelectEntityRow extends LitElement implements LovelaceRow {
setTimeout(() => {
const newStateObj = this.hass!.states[this._config!.entity];
if (newStateObj === stateObj) {
this._selectedEntityRow = stateObj.state;
this._selectedEntityRow = undefined;
}
}, 2000)
);