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,35 +23,36 @@ export const navigate = async (path: string, options?: NavigateOptions) => {
console.warn("Navigation blocked, because dialog refused to close");
return false;
}
}
return new Promise<boolean>((resolve) => {
// need to wait for history state to be updated in case a dialog was closed
setTimeout(async () => {
const replace = options?.replace || false;
if (__DEMO__) {
if (replace) {
history.replaceState(
history.state?.root ? { root: true } : (options?.data ?? null),
"",
`${mainWindow.location.pathname}#${path}`
);
} else {
mainWindow.location.hash = path;
}
} else if (replace) {
history.replaceState(
history.state?.root ? { root: true } : (options?.data ?? null),
"",
path
);
} else {
history.pushState(options?.data ?? null, "", path);
}
fireEvent(mainWindow, "location-changed", {
replace,
return new Promise<boolean>((resolve) => {
// need to wait for history state to be updated in case a dialog was closed
setTimeout(() => {
navigate(path, options).then(resolve);
});
resolve(true);
});
}
const replace = options?.replace || false;
if (__DEMO__) {
if (replace) {
history.replaceState(
history.state?.root ? { root: true } : (options?.data ?? null),
"",
`${mainWindow.location.pathname}#${path}`
);
} else {
mainWindow.location.hash = path;
}
} else if (replace) {
history.replaceState(
history.state?.root ? { root: true } : (options?.data ?? null),
"",
path
);
} else {
history.pushState(options?.data ?? null, "", path);
}
fireEvent(mainWindow, "location-changed", {
replace,
});
return true;
};

View File

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