Fix menu button when sidebar is always_hidden (#17059)

This commit is contained in:
Bram Kragten 2023-06-28 13:34:48 +02:00 committed by GitHub
parent 927c6dd778
commit ce9380e4d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,25 +73,25 @@ class HaMenuButton extends LitElement {
return; 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; const oldShowButton =
let newNarrow: boolean | undefined; oldNarrow || oldHass?.dockedSidebar === "always_hidden";
if (changedProps.has("narrow")) { const showButton =
oldNarrow = changedProps.get("narrow"); this.narrow || this.hass.dockedSidebar === "always_hidden";
newNarrow = this.narrow;
} else if (oldHass) {
oldNarrow = oldHass.dockedSidebar === "always_hidden";
newNarrow = this.hass.dockedSidebar === "always_hidden";
}
if (oldNarrow === newNarrow) { if (oldShowButton === showButton) {
return; return;
} }
this.style.display = newNarrow || this._alwaysVisible ? "initial" : "none"; this.style.display = showButton || this._alwaysVisible ? "initial" : "none";
if (!newNarrow) { if (!showButton) {
if (this._unsubNotifications) { if (this._unsubNotifications) {
this._unsubNotifications(); this._unsubNotifications();
this._unsubNotifications = undefined; this._unsubNotifications = undefined;