1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-02-14 23:18:21 +00:00

Correct value update for 'ha-selector-select' elements displaying as radio buttons. (#29612)

* Correct options reset in ha-selector-select

Separate out the handling of resetting for select elements in `ha-selector-select` from the main value changed callback.

This fixes a bug that prevented `ha-selector-select` elements operating in `list` mode from updating their value due to recent changes in the reset logc.

* Split radio changed callback for consistency
This commit is contained in:
Tom Carpenter
2026-02-13 13:02:16 +00:00
committed by GitHub
parent 93a0f37974
commit 9f10bc1371

View File

@@ -93,7 +93,7 @@ export class HaSelectSelector extends LitElement {
<ha-select-box
.options=${options}
.value=${this.value as string | undefined}
@value-changed=${this._valueChanged}
@value-changed=${this._selectChanged}
.maxColumns=${this.selector.select?.box_max_columns}
.hass=${this.hass}
></ha-select-box>
@@ -120,7 +120,7 @@ export class HaSelectSelector extends LitElement {
.checked=${item.value === this.value}
.value=${item.value}
.disabled=${item.disabled || this.disabled}
@change=${this._valueChanged}
@change=${this._radioChanged}
></ha-radio>
</ha-formfield>
`
@@ -236,7 +236,7 @@ export class HaSelectSelector extends LitElement {
.disabled=${this.disabled}
.required=${this.required}
clearable
@selected=${this._valueChanged}
@selected=${this._selectChanged}
.options=${options}
>
</ha-select>
@@ -282,16 +282,24 @@ export class HaSelectSelector extends LitElement {
);
}
private _valueChanged(ev) {
private _radioChanged(ev) {
ev.stopPropagation();
this._valueChanged(ev);
}
private _selectChanged(ev) {
ev.stopPropagation();
// Additional handling for reset of select elements
if (ev.detail?.value === undefined && this.value !== undefined) {
fireEvent(this, "value-changed", {
value: undefined,
});
return;
}
this._valueChanged(ev);
}
private _valueChanged(ev) {
const value = ev.detail?.value || ev.target.value;
if (this.disabled || value === undefined || value === (this.value ?? "")) {
return;