Skip to content

Commit

Permalink
Fix choose add option (#18493)
Browse files Browse the repository at this point in the history
  • Loading branch information
karwosts authored and bramkragten committed Nov 1, 2023
1 parent 3b553a3 commit e6cfe74
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export class HaChooseAction extends LitElement implements ActionElement {

private _duplicateOption(ev) {
const index = (ev.target as any).idx;
this._addOption(deepClone(ensureArray(this.action.choose)[index]));
this._createOption(deepClone(ensureArray(this.action.choose)[index]));
}

protected firstUpdated() {
Expand Down Expand Up @@ -399,11 +399,15 @@ export class HaChooseAction extends LitElement implements ActionElement {
});
}

private _addOption(opt?: ChooseActionChoice) {
private _addOption() {
this._createOption({ conditions: [], sequence: [] });
}

private _createOption(opt: ChooseActionChoice) {
const choose = this.action.choose
? [...ensureArray(this.action.choose)]
: [];
choose.push(opt ?? { conditions: [], sequence: [] });
choose.push(opt);
fireEvent(this, "value-changed", {
value: { ...this.action, choose },
});
Expand Down

0 comments on commit e6cfe74

Please sign in to comment.