From 77c2444be82031cd12444d9249577818eaac1b19 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Thu, 27 Nov 2025 11:42:36 +0100 Subject: [PATCH] Restore sidebar view when clicking back (#28167) --- src/panels/lovelace/views/hui-sections-view.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/panels/lovelace/views/hui-sections-view.ts b/src/panels/lovelace/views/hui-sections-view.ts index 7c24baac8f..ab40ce42c4 100644 --- a/src/panels/lovelace/views/hui-sections-view.ts +++ b/src/panels/lovelace/views/hui-sections-view.ts @@ -123,6 +123,7 @@ export class SectionsView extends LitElement implements LovelaceViewElement { "section-visibility-changed", this._sectionVisibilityChanged ); + this._showSidebar = Boolean(window.history.state?.sidebar); } disconnectedCallback(): void { @@ -428,6 +429,12 @@ export class SectionsView extends LitElement implements LovelaceViewElement { this._showSidebar = !this._showSidebar; + // Add sidebar state to history + window.history.replaceState( + { ...window.history.state, sidebar: this._showSidebar }, + "" + ); + // Restore scroll position after view updates this.updateComplete.then(() => { const scrollY = this._showSidebar