From fe257ef75b2e1221133185d9a9eff556d1a9c9eb Mon Sep 17 00:00:00 2001 From: boban Date: Sun, 17 May 2026 12:50:11 +0200 Subject: [PATCH] =?UTF-8?q?fix(bug-2):=20isCollapsed=20as=20plain=20reacti?= =?UTF-8?q?ve=20property=20=E2=80=94=20getters=20unreliable=20in=20Alpine?= =?UTF-8?q?=20stores?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/js/bootstrap.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/resources/js/bootstrap.js b/resources/js/bootstrap.js index 0fa9e9c..69ad520 100644 --- a/resources/js/bootstrap.js +++ b/resources/js/bootstrap.js @@ -63,10 +63,14 @@ document.addEventListener('alpine:init', () => { mobileOpen: false, collapsed: localStorage.getItem('sidebarCollapsed') === 'true', isMobile: window.innerWidth < 768, - get isCollapsed() { return this.collapsed && ! this.isMobile; }, + isCollapsed: false, init() { + this.isCollapsed = this.collapsed && ! this.isMobile; this._syncDataset(); - window.addEventListener('resize', () => { this.isMobile = window.innerWidth < 768; }); + window.addEventListener('resize', () => { + this.isMobile = window.innerWidth < 768; + this.isCollapsed = this.collapsed && ! this.isMobile; + }); }, _syncDataset() { if (this.collapsed) { @@ -77,6 +81,7 @@ document.addEventListener('alpine:init', () => { }, toggle() { this.collapsed = ! this.collapsed; + this.isCollapsed = this.collapsed && ! this.isMobile; localStorage.setItem('sidebarCollapsed', this.collapsed); this._syncDataset(); window.dispatchEvent(new CustomEvent('sidebar-toggled', { detail: { collapsed: this.collapsed } }));