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