Don't save new automation when save dialog is cancelled (#18655)

This commit is contained in:
karwosts 2023-11-15 09:03:47 -08:00 committed by GitHub
parent b35e5abd83
commit 08a7a10e1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -697,7 +697,7 @@ 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!,
@ -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<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;