From db5e840aecaa516f642d3345450eaedf0642570b Mon Sep 17 00:00:00 2001 From: "aditya.chandel" <8075870+adityachandelgit@users.noreply.github.com> Date: Fri, 29 Aug 2025 11:09:41 -0600 Subject: [PATCH] Hide sidebar by default on mobile devices --- .../filters/sidebar-filter-toggle-pref-service.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/booklore-ui/src/app/book/components/book-browser/filters/sidebar-filter-toggle-pref-service.ts b/booklore-ui/src/app/book/components/book-browser/filters/sidebar-filter-toggle-pref-service.ts index 9ce251369..5c72c90c2 100644 --- a/booklore-ui/src/app/book/components/book-browser/filters/sidebar-filter-toggle-pref-service.ts +++ b/booklore-ui/src/app/book/components/book-browser/filters/sidebar-filter-toggle-pref-service.ts @@ -16,6 +16,9 @@ export class SidebarFilterTogglePrefService { readonly showFilter$ = this.showFilterSubject.asObservable(); constructor() { + const isNarrow = window.innerWidth <= 768; + this.showFilterSubject = new BehaviorSubject(!isNarrow); + this.showFilter$ = this.showFilterSubject.asObservable(); this.loadFromStorage(); } @@ -48,9 +51,12 @@ export class SidebarFilterTogglePrefService { } private loadFromStorage(): void { - const saved = this.localStorageService.get(this.STORAGE_KEY); - if (saved !== null) { - this.showFilterSubject.next(saved); + const isNarrow = window.innerWidth <= 768; + if (isNarrow) { + this.showFilterSubject.next(false); + } else { + const saved = this.localStorageService.get(this.STORAGE_KEY); + this.showFilterSubject.next(saved !== null ? saved : true); } } }