Fix new automation dialog in Firefox (#23319)

This commit is contained in:
Petar Petrov 2024-12-17 16:00:00 +02:00 committed by GitHub
parent 2718801c69
commit 48819a59e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 30 deletions

View File

@ -23,10 +23,13 @@ export const navigate = async (path: string, options?: NavigateOptions) => {
console.warn("Navigation blocked, because dialog refused to close"); console.warn("Navigation blocked, because dialog refused to close");
return false; return false;
} }
}
return new Promise<boolean>((resolve) => { return new Promise<boolean>((resolve) => {
// need to wait for history state to be updated in case a dialog was closed // need to wait for history state to be updated in case a dialog was closed
setTimeout(async () => { setTimeout(() => {
navigate(path, options).then(resolve);
});
});
}
const replace = options?.replace || false; const replace = options?.replace || false;
if (__DEMO__) { if (__DEMO__) {
@ -51,7 +54,5 @@ export const navigate = async (path: string, options?: NavigateOptions) => {
fireEvent(mainWindow, "location-changed", { fireEvent(mainWindow, "location-changed", {
replace, replace,
}); });
resolve(true); return true;
});
});
}; };

View File

@ -205,7 +205,6 @@ class DialogNewAutomation extends LitElement implements HassDialog {
return; return;
} }
const path = (ev.currentTarget! as any).path; const path = (ev.currentTarget! as any).path;
this.closeDialog();
if (this._mode === "script") { if (this._mode === "script") {
showScriptEditor({ use_blueprint: { path } }); showScriptEditor({ use_blueprint: { path } });
} else { } else {
@ -217,7 +216,6 @@ class DialogNewAutomation extends LitElement implements HassDialog {
if (!shouldHandleRequestSelectedEvent(ev)) { if (!shouldHandleRequestSelectedEvent(ev)) {
return; return;
} }
this.closeDialog();
if (this._mode === "script") { if (this._mode === "script") {
showScriptEditor(); showScriptEditor();
} else { } else {