From 08a7a10e1c3fd7b58814095513fab2c04de50ed3 Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Wed, 15 Nov 2023 09:03:47 -0800 Subject: [PATCH] Don't save new automation when save dialog is cancelled (#18655) --- src/panels/config/automation/ha-automation-editor.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/panels/config/automation/ha-automation-editor.ts b/src/panels/config/automation/ha-automation-editor.ts index 50302c2801..2a4ba09139 100644 --- a/src/panels/config/automation/ha-automation-editor.ts +++ b/src/panels/config/automation/ha-automation-editor.ts @@ -697,7 +697,7 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) { this._mode = "yaml"; } - private async _promptAutomationAlias(): Promise { + private async _promptAutomationAlias(): Promise { return new Promise((resolve) => { showAutomationRenameDialog(this, { config: this._config!, @@ -705,9 +705,9 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) { this._config = config; this._dirty = true; this.requestUpdate(); - resolve(); + resolve(true); }, - onClose: () => resolve(), + onClose: () => resolve(false), }); }); } @@ -730,7 +730,10 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) { private async _saveAutomation(): Promise { const id = this.automationId || String(Date.now()); if (!this.automationId) { - await this._promptAutomationAlias(); + const saved = await this._promptAutomationAlias(); + if (!saved) { + return; + } } this._validationErrors = undefined;