Skip to content

Commit

Permalink
Don't save new automation when save dialog is cancelled (#18655)
Browse files Browse the repository at this point in the history
  • Loading branch information
karwosts authored Nov 15, 2023
1 parent b35e5ab commit 08a7a10
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/panels/config/automation/ha-automation-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,17 +697,17 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
this._mode = "yaml";
}

private async _promptAutomationAlias(): Promise<void> {
private async _promptAutomationAlias(): Promise<boolean> {
return new Promise((resolve) => {
showAutomationRenameDialog(this, {
config: this._config!,
updateAutomation: (config) => {
this._config = config;
this._dirty = true;
this.requestUpdate();
resolve();
resolve(true);
},
onClose: () => resolve(),
onClose: () => resolve(false),
});
});
}
Expand All @@ -730,7 +730,10 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
private async _saveAutomation(): Promise<void> {
const id = this.automationId || String(Date.now());
if (!this.automationId) {
await this._promptAutomationAlias();
const saved = await this._promptAutomationAlias();
if (!saved) {
return;
}
}

this._validationErrors = undefined;
Expand Down

0 comments on commit 08a7a10

Please sign in to comment.