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); } } }