mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
Fix dialog navigation by making navigate()
async
This commit is contained in:
parent
e4fc21c991
commit
142e674020
@ -16,28 +16,32 @@ export interface NavigateOptions {
|
|||||||
export const navigate = (path: string, options?: NavigateOptions) => {
|
export const navigate = (path: string, options?: NavigateOptions) => {
|
||||||
const replace = options?.replace || false;
|
const replace = options?.replace || false;
|
||||||
|
|
||||||
if (__DEMO__) {
|
setTimeout(() => {
|
||||||
if (replace) {
|
if (__DEMO__) {
|
||||||
|
if (replace) {
|
||||||
|
mainWindow.history.replaceState(
|
||||||
|
mainWindow.history.state?.root
|
||||||
|
? { root: true }
|
||||||
|
: (options?.data ?? null),
|
||||||
|
"",
|
||||||
|
`${mainWindow.location.pathname}#${path}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
mainWindow.location.hash = path;
|
||||||
|
}
|
||||||
|
} else if (replace) {
|
||||||
mainWindow.history.replaceState(
|
mainWindow.history.replaceState(
|
||||||
mainWindow.history.state?.root
|
mainWindow.history.state?.root
|
||||||
? { root: true }
|
? { root: true }
|
||||||
: (options?.data ?? null),
|
: (options?.data ?? null),
|
||||||
"",
|
"",
|
||||||
`${mainWindow.location.pathname}#${path}`
|
path
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
mainWindow.location.hash = path;
|
mainWindow.history.pushState(options?.data ?? null, "", path);
|
||||||
}
|
}
|
||||||
} else if (replace) {
|
fireEvent(mainWindow, "location-changed", {
|
||||||
mainWindow.history.replaceState(
|
replace,
|
||||||
mainWindow.history.state?.root ? { root: true } : (options?.data ?? null),
|
});
|
||||||
"",
|
|
||||||
path
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
mainWindow.history.pushState(options?.data ?? null, "", path);
|
|
||||||
}
|
|
||||||
fireEvent(mainWindow, "location-changed", {
|
|
||||||
replace,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user