mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix new automation dialog in Firefox (#23319)
This commit is contained in:
parent
2718801c69
commit
48819a59e7
@ -23,35 +23,36 @@ 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(() => {
|
||||||
setTimeout(async () => {
|
navigate(path, options).then(resolve);
|
||||||
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,
|
|
||||||
});
|
});
|
||||||
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;
|
||||||
};
|
};
|
||||||
|
@ -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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user