mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-20 02:38:53 +00:00
Restore sidebar view when clicking back (#28167)
This commit is contained in:
@@ -123,6 +123,7 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
|
|||||||
"section-visibility-changed",
|
"section-visibility-changed",
|
||||||
this._sectionVisibilityChanged
|
this._sectionVisibilityChanged
|
||||||
);
|
);
|
||||||
|
this._showSidebar = Boolean(window.history.state?.sidebar);
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnectedCallback(): void {
|
disconnectedCallback(): void {
|
||||||
@@ -428,6 +429,12 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
|
|||||||
|
|
||||||
this._showSidebar = !this._showSidebar;
|
this._showSidebar = !this._showSidebar;
|
||||||
|
|
||||||
|
// Add sidebar state to history
|
||||||
|
window.history.replaceState(
|
||||||
|
{ ...window.history.state, sidebar: this._showSidebar },
|
||||||
|
""
|
||||||
|
);
|
||||||
|
|
||||||
// Restore scroll position after view updates
|
// Restore scroll position after view updates
|
||||||
this.updateComplete.then(() => {
|
this.updateComplete.then(() => {
|
||||||
const scrollY = this._showSidebar
|
const scrollY = this._showSidebar
|
||||||
|
|||||||
Reference in New Issue
Block a user