From d4218250af97be89e7579e67f6cc0fc5ebb0c431 Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Wed, 1 Nov 2023 01:37:26 -0700 Subject: [PATCH] Fix choose add option (#18493) --- .../action/types/ha-automation-action-choose.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/panels/config/automation/action/types/ha-automation-action-choose.ts b/src/panels/config/automation/action/types/ha-automation-action-choose.ts index 6bb67e44d0..0654480f31 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-choose.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-choose.ts @@ -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() { @@ -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 }, });