Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading