Skip to content

Commit 77c2444

Browse files
authored
Restore sidebar view when clicking back (#28167)
1 parent e5cb26c commit 77c2444

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/panels/lovelace/views/hui-sections-view.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
123123
"section-visibility-changed",
124124
this._sectionVisibilityChanged
125125
);
126+
this._showSidebar = Boolean(window.history.state?.sidebar);
126127
}
127128

128129
disconnectedCallback(): void {
@@ -428,6 +429,12 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
428429

429430
this._showSidebar = !this._showSidebar;
430431

432+
// Add sidebar state to history
433+
window.history.replaceState(
434+
{ ...window.history.state, sidebar: this._showSidebar },
435+
""
436+
);
437+
431438
// Restore scroll position after view updates
432439
this.updateComplete.then(() => {
433440
const scrollY = this._showSidebar

0 commit comments

Comments
 (0)