From d7c3ff3e9d936d04cc70a55d90bb6ca7fabc21db Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Wed, 7 Jun 2023 02:27:50 -0700 Subject: [PATCH] Fix cancel button in automation row alias rename dialog (#16810) --- .../action/ha-automation-action-row.ts | 24 ++++++++++--------- .../condition/ha-automation-condition-row.ts | 19 ++++++++------- .../trigger/ha-automation-trigger-row.ts | 24 ++++++++++--------- 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/panels/config/automation/action/ha-automation-action-row.ts b/src/panels/config/automation/action/ha-automation-action-row.ts index 4aa1ded268..0819a14287 100644 --- a/src/panels/config/automation/action/ha-automation-action-row.ts +++ b/src/panels/config/automation/action/ha-automation-action-row.ts @@ -524,17 +524,19 @@ export default class HaAutomationActionRow extends LitElement { defaultValue: this.action.alias, confirmText: this.hass.localize("ui.common.submit"), }); - const value = { ...this.action }; - if (!alias) { - delete value.alias; - } else { - value.alias = alias; - } - fireEvent(this, "value-changed", { - value, - }); - if (this._yamlMode) { - this._yamlEditor?.setValue(value); + if (alias !== null) { + const value = { ...this.action }; + if (alias === "") { + delete value.alias; + } else { + value.alias = alias; + } + fireEvent(this, "value-changed", { + value, + }); + if (this._yamlMode) { + this._yamlEditor?.setValue(value); + } } } diff --git a/src/panels/config/automation/condition/ha-automation-condition-row.ts b/src/panels/config/automation/condition/ha-automation-condition-row.ts index ebc2b5cf1a..8f6cd63441 100644 --- a/src/panels/config/automation/condition/ha-automation-condition-row.ts +++ b/src/panels/config/automation/condition/ha-automation-condition-row.ts @@ -471,16 +471,17 @@ export default class HaAutomationConditionRow extends LitElement { defaultValue: this.condition.alias, confirmText: this.hass.localize("ui.common.submit"), }); - - const value = { ...this.condition }; - if (!alias) { - delete value.alias; - } else { - value.alias = alias; + if (alias !== null) { + const value = { ...this.condition }; + if (alias === "") { + delete value.alias; + } else { + value.alias = alias; + } + fireEvent(this, "value-changed", { + value, + }); } - fireEvent(this, "value-changed", { - value, - }); } public expand() { diff --git a/src/panels/config/automation/trigger/ha-automation-trigger-row.ts b/src/panels/config/automation/trigger/ha-automation-trigger-row.ts index 94094c4c79..52b51686bc 100644 --- a/src/panels/config/automation/trigger/ha-automation-trigger-row.ts +++ b/src/panels/config/automation/trigger/ha-automation-trigger-row.ts @@ -581,17 +581,19 @@ export default class HaAutomationTriggerRow extends LitElement { confirmText: this.hass.localize("ui.common.submit"), }); - const value = { ...this.trigger }; - if (!alias) { - delete value.alias; - } else { - value.alias = alias; - } - fireEvent(this, "value-changed", { - value, - }); - if (this._yamlMode) { - this._yamlEditor?.setValue(value); + if (alias !== null) { + const value = { ...this.trigger }; + if (alias === "") { + delete value.alias; + } else { + value.alias = alias; + } + fireEvent(this, "value-changed", { + value, + }); + if (this._yamlMode) { + this._yamlEditor?.setValue(value); + } } }