Close the drawer when picking a panel when in forced narrow mode (#3402)

This commit is contained in:
Paulus Schoutsen 2019-07-21 11:07:26 -07:00 committed by GitHub
parent 2fd75742f1
commit 56c08a1d07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,8 +44,7 @@ class HomeAssistantMain extends LitElement {
return;
}
const sidebarNarrow =
this.narrow || this.hass.dockedSidebar === "always_hidden";
const sidebarNarrow = this._sidebarNarrow;
const disableSwipe =
!sidebarNarrow || NON_SWIPABLE_PANELS.indexOf(hass.panelUrl) !== -1;
@ -91,7 +90,7 @@ class HomeAssistantMain extends LitElement {
import(/* webpackChunkName: "ha-sidebar" */ "../components/ha-sidebar");
this.addEventListener("hass-toggle-menu", () => {
if (this.narrow || this.hass.dockedSidebar === "always_hidden") {
if (this._sidebarNarrow) {
if (this.drawer.opened) {
this.drawer.close();
} else {
@ -120,7 +119,7 @@ class HomeAssistantMain extends LitElement {
this.narrow || this.hass.dockedSidebar !== "auto"
);
if (changedProps.has("route") && this.narrow) {
if (changedProps.has("route") && this._sidebarNarrow) {
this.drawer.close();
}
@ -136,6 +135,10 @@ class HomeAssistantMain extends LitElement {
this.narrow = ev.detail.value;
}
private get _sidebarNarrow() {
return this.narrow || this.hass.dockedSidebar === "always_hidden";
}
private get drawer(): AppDrawerElement {
return this.shadowRoot!.querySelector("app-drawer")!;
}