mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-20 15:56:35 +00:00
Fix custom panel/hass.io navigation (#3034)
* Hass.io: use correct function for firing evenet * Fix navigation from custom panel
This commit is contained in:
parent
c134464f6a
commit
f4319d9b13
@ -87,7 +87,8 @@ class HassioMain extends EventsMixin(NavigateMixin(PolymerElement)) {
|
||||
// open and close events. These events are a no-op in newer versions of
|
||||
// Home Assistant.
|
||||
this.addEventListener("hass-toggle-menu", () => {
|
||||
window.parent.customPanel.fire(
|
||||
fireEvent(
|
||||
window.parent.customPanel,
|
||||
this.hass.dockedSidebar ? "hass-close-menu" : "hass-open-menu"
|
||||
);
|
||||
});
|
||||
@ -130,7 +131,7 @@ class HassioMain extends EventsMixin(NavigateMixin(PolymerElement)) {
|
||||
if (route.path === "" && route.prefix === "/hassio") {
|
||||
this.navigate("/hassio/dashboard", true);
|
||||
}
|
||||
this.fire("iron-resize");
|
||||
fireEvent(this, "iron-resize");
|
||||
}
|
||||
|
||||
equalsAddon(page) {
|
||||
|
@ -72,13 +72,14 @@ function initialize(panel: Panel, properties: {}) {
|
||||
}
|
||||
};
|
||||
panelEl!.addEventListener("hass-toggle-menu", forwardEvent);
|
||||
window.addEventListener("location-changed", (ev: any) =>
|
||||
navigate(
|
||||
window.parent.customPanel,
|
||||
window.location.pathname,
|
||||
ev.detail ? ev.detail.replace : false
|
||||
)
|
||||
);
|
||||
window.addEventListener("location-changed", (ev: any) => {
|
||||
if (window.parent.customPanel) {
|
||||
window.parent.customPanel.navigate(
|
||||
window.location.pathname,
|
||||
ev.detail ? ev.detail.replace : false
|
||||
);
|
||||
}
|
||||
});
|
||||
setProperties({ panel, ...properties });
|
||||
document.body.appendChild(panelEl!);
|
||||
},
|
||||
|
@ -4,6 +4,7 @@ import { createCustomPanelElement } from "../../util/custom-panel/create-custom-
|
||||
import { setCustomPanelProperties } from "../../util/custom-panel/set-custom-panel-properties";
|
||||
import { HomeAssistant, Route, Panel } from "../../types";
|
||||
import { CustomPanelConfig } from "../../data/panel_custom";
|
||||
import { navigate } from "../../common/navigate";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
@ -18,6 +19,12 @@ export class HaPanelCustom extends UpdatingElement {
|
||||
@property() public panel!: Panel;
|
||||
private _setProperties?: (props: {}) => void | undefined;
|
||||
|
||||
// Since navigate fires events on `window`, we need to expose this as a function
|
||||
// to allow custom panels to forward their location changes to the main window
|
||||
// instead of their iframe window.
|
||||
public navigate = (path: string, replace?: boolean) =>
|
||||
navigate(this, path, replace);
|
||||
|
||||
public registerIframe(initialize, setProperties) {
|
||||
initialize(this.panel, {
|
||||
hass: this.hass,
|
||||
|
Loading…
x
Reference in New Issue
Block a user