diff --git a/custom_components/bahmcloud_store/panel/panel.js b/custom_components/bahmcloud_store/panel/panel.js index d351a8d..eef05ca 100644 --- a/custom_components/bahmcloud_store/panel/panel.js +++ b/custom_components/bahmcloud_store/panel/panel.js @@ -40,6 +40,45 @@ class BahmcloudStorePanel extends HTMLElement { } } + // --- Mobile navigation helpers --- + + _toggleMenu() { + // Preferred: HA listens to these events in many builds + try { + window.dispatchEvent(new CustomEvent("hass-toggle-menu", { bubbles: true, composed: true })); + window.dispatchEvent(new CustomEvent("hass-toggle-drawer", { bubbles: true, composed: true })); + } catch (_) {} + + // Fallback: try to find the drawer and toggle it (best-effort) + try { + const ha = document.querySelector("home-assistant"); + const main = ha?.shadowRoot?.querySelector("home-assistant-main"); + const drawerLayout = + main?.shadowRoot?.querySelector("app-drawer-layout") || + main?.shadowRoot?.querySelector("ha-drawer") || + main?.shadowRoot?.querySelector("ha-sidebar"); + + if (drawerLayout?.toggleDrawer) { + drawerLayout.toggleDrawer(); + return; + } + } catch (_) {} + + // If nothing works, show a hint + this._error = "Unable to open the sidebar on this client. Use the browser back button."; + this._update(); + } + + _goBack() { + // Works even if HA chrome is hidden + try { + history.back(); + } catch (_) { + // fallback + window.location.href = "/"; + } + } + async _addCustomRepo() { if (!this._hass) return; @@ -93,13 +132,66 @@ class BahmcloudStorePanel extends HTMLElement { -