Cleanup else/default block when deleting all actions (#19298)

pull/19326/head
karwosts 2024-01-08 05:10:23 -08:00 committed by GitHub
parent f5fc66f47e
commit ec2ae15e3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 15 deletions

View File

@ -468,13 +468,16 @@ export class HaChooseAction extends LitElement implements ActionElement {
private _defaultChanged(ev: CustomEvent) {
ev.stopPropagation();
const value = ev.detail.value as Action[];
fireEvent(this, "value-changed", {
value: {
...this.action,
default: value,
},
});
this._showDefault = true;
const defaultAction = ev.detail.value as Action[];
const newValue: ChooseAction = {
...this.action,
default: defaultAction,
};
if (defaultAction.length === 0) {
delete newValue.default;
}
fireEvent(this, "value-changed", { value: newValue });
}
static get styles(): CSSResultGroup {

View File

@ -117,14 +117,16 @@ export class HaIfAction extends LitElement implements ActionElement {
private _elseChanged(ev: CustomEvent) {
ev.stopPropagation();
const value = ev.detail.value as Action[];
fireEvent(this, "value-changed", {
value: {
...this.action,
else: value,
},
});
this._showElse = true;
const elseAction = ev.detail.value as Action[];
const newValue: IfAction = {
...this.action,
else: elseAction,
};
if (elseAction.length === 0) {
delete newValue.else;
}
fireEvent(this, "value-changed", { value: newValue });
}
static get styles(): CSSResultGroup {