diff --git a/custom_components/bahmcloud_store/panel/panel.js b/custom_components/bahmcloud_store/panel/panel.js index e88bd6c..6b8c023 100644 --- a/custom_components/bahmcloud_store/panel/panel.js +++ b/custom_components/bahmcloud_store/panel/panel.js @@ -40,26 +40,19 @@ class BahmcloudStorePanel extends HTMLElement { } } - // --- Mobile navigation helpers --- - _isDesktop() { - // If the viewport is wide enough, HA typically shows the sidebar permanently. - // We treat this as "desktop" and hide/disable the menu toggle. return window.matchMedia && window.matchMedia("(min-width: 1024px)").matches; } _toggleMenu() { - // On desktop the sidebar is usually always visible; do nothing. if (this._isDesktop()) return; - // Primary: dispatch the standard HA event from THIS element so it bubbles. try { const ev = new Event("hass-toggle-menu", { bubbles: true, composed: true }); this.dispatchEvent(ev); - return; // often enough on mobile + return; } catch (_) {} - // Secondary: try again via host/root try { const host = this.shadowRoot?.host; if (host) { @@ -69,44 +62,6 @@ class BahmcloudStorePanel extends HTMLElement { } } catch (_) {} - // Fallback DOM attempts - try { - const ha = document.querySelector("home-assistant"); - const haRoot = ha?.shadowRoot; - - const main = - haRoot?.querySelector("home-assistant-main") || - haRoot?.querySelector("home-assistant-main#main"); - - const mainRoot = main?.shadowRoot; - - const drawer = - mainRoot?.querySelector("mwc-drawer") || - mainRoot?.querySelector("ha-drawer") || - mainRoot?.querySelector("app-drawer-layout"); - - if (drawer) { - if ("open" in drawer) { - drawer.open = true; - return; - } - if (typeof drawer.toggleDrawer === "function") { - drawer.toggleDrawer(); - return; - } - } - - const layout = - mainRoot?.querySelector("ha-panel-lovelace") || - mainRoot?.querySelector("ha-panel"); - - if (layout && typeof layout.toggleMenu === "function") { - layout.toggleMenu(); - return; - } - } catch (_) {} - - // Only show an error on mobile if everything failed. this._error = "Unable to open the sidebar on this client. Use the back button."; this._update(); } @@ -170,189 +125,98 @@ class BahmcloudStorePanel extends HTMLElement { root.innerHTML = `
-