mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 16:56:35 +00:00
Add if replace was used when sending navigation events (#2970)
This commit is contained in:
parent
dc16abd637
commit
40025d44c2
@ -1,5 +1,14 @@
|
|||||||
import { fireEvent } from "./dom/fire_event";
|
import { fireEvent } from "./dom/fire_event";
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
// for fire event
|
||||||
|
interface HASSDomEvents {
|
||||||
|
"location-changed": {
|
||||||
|
replace: boolean;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const navigate = (
|
export const navigate = (
|
||||||
_node: any,
|
_node: any,
|
||||||
path: string,
|
path: string,
|
||||||
@ -18,5 +27,7 @@ export const navigate = (
|
|||||||
history.pushState(null, "", path);
|
history.pushState(null, "", path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fireEvent(window, "location-changed");
|
fireEvent(window, "location-changed", {
|
||||||
|
replace,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
@ -56,8 +56,11 @@ function initialize(panel, properties) {
|
|||||||
const forwardEvent = (ev) =>
|
const forwardEvent = (ev) =>
|
||||||
window.parent.customPanel.fire(ev.type, ev.detail);
|
window.parent.customPanel.fire(ev.type, ev.detail);
|
||||||
root.addEventListener("hass-toggle-menu", forwardEvent);
|
root.addEventListener("hass-toggle-menu", forwardEvent);
|
||||||
window.addEventListener("location-changed", () =>
|
window.addEventListener("location-changed", (ev) =>
|
||||||
window.parent.customPanel.navigate(window.location.pathname)
|
window.parent.customPanel.navigate(
|
||||||
|
window.location.pathname,
|
||||||
|
ev.detail ? ev.detail.replace : false
|
||||||
|
)
|
||||||
);
|
);
|
||||||
setProperties(Object.assign({ panel }, properties));
|
setProperties(Object.assign({ panel }, properties));
|
||||||
document.body.appendChild(root);
|
document.body.appendChild(root);
|
||||||
|
@ -25,7 +25,6 @@ declare global {
|
|||||||
"iron-resize": undefined;
|
"iron-resize": undefined;
|
||||||
"config-refresh": undefined;
|
"config-refresh": undefined;
|
||||||
"ha-refresh-cloud-status": undefined;
|
"ha-refresh-cloud-status": undefined;
|
||||||
"location-changed": undefined;
|
|
||||||
"hass-notification": {
|
"hass-notification": {
|
||||||
message: string;
|
message: string;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user