From ce9380e4d7d2714fd6538b171dca3ba82abb320c Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 28 Jun 2023 13:34:48 +0200 Subject: [PATCH] Fix menu button when sidebar is always_hidden (#17059) --- src/components/ha-menu-button.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/ha-menu-button.ts b/src/components/ha-menu-button.ts index 3bb80a0e04..2246dd136b 100644 --- a/src/components/ha-menu-button.ts +++ b/src/components/ha-menu-button.ts @@ -73,25 +73,25 @@ class HaMenuButton extends LitElement { return; } - const oldHass = changedProps.get("hass") as HomeAssistant | undefined; + const oldHass = changedProps.has("hass") + ? (changedProps.get("hass") as HomeAssistant | undefined) + : this.hass; + const oldNarrow = changedProps.has("narrow") + ? (changedProps.get("narrow") as boolean | undefined) + : this.narrow; - let oldNarrow: boolean | undefined; - let newNarrow: boolean | undefined; - if (changedProps.has("narrow")) { - oldNarrow = changedProps.get("narrow"); - newNarrow = this.narrow; - } else if (oldHass) { - oldNarrow = oldHass.dockedSidebar === "always_hidden"; - newNarrow = this.hass.dockedSidebar === "always_hidden"; - } + const oldShowButton = + oldNarrow || oldHass?.dockedSidebar === "always_hidden"; + const showButton = + this.narrow || this.hass.dockedSidebar === "always_hidden"; - if (oldNarrow === newNarrow) { + if (oldShowButton === showButton) { return; } - this.style.display = newNarrow || this._alwaysVisible ? "initial" : "none"; + this.style.display = showButton || this._alwaysVisible ? "initial" : "none"; - if (!newNarrow) { + if (!showButton) { if (this._unsubNotifications) { this._unsubNotifications(); this._unsubNotifications = undefined;