From ce0caa5685efca56eb107b615e6871908b86ee5a Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Mon, 23 Mar 2026 18:22:20 +0100 Subject: [PATCH] fix(core): don't overwrite currentPage set by child Alpine components The store init-alpine.js init() was unconditionally setting currentPage from the URL path segment, overwriting the value set by child components like storeLoyaltyProgram (currentPage: 'loyalty-program'). This caused sidebar menu items to not highlight on pages where the URL segment doesn't match the menu item ID (e.g., /loyalty/program vs loyalty-program). Now only sets currentPage from URL if the child hasn't already set it. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../core/static/store/js/init-alpine.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/modules/core/static/store/js/init-alpine.js b/app/modules/core/static/store/js/init-alpine.js index 5de4df15..83ad6c97 100644 --- a/app/modules/core/static/store/js/init-alpine.js +++ b/app/modules/core/static/store/js/init-alpine.js @@ -65,14 +65,16 @@ function data() { openSections: getStoreSidebarSectionsFromStorage(), init() { - // Set current page from URL - const path = window.location.pathname; - const segments = path.split('/').filter(Boolean); - // For /store/ABC/orders/123 -> 'orders' (skip numeric IDs) - const last = segments[segments.length - 1] || 'dashboard'; - this.currentPage = /^\d+$/.test(last) && segments.length > 2 - ? segments[segments.length - 2] - : last; + // Set current page from URL (only if not already set by child component) + if (!this.currentPage) { + const path = window.location.pathname; + const segments = path.split('/').filter(Boolean); + // For /store/ABC/orders/123 -> 'orders' (skip numeric IDs) + const last = segments[segments.length - 1] || 'dashboard'; + this.currentPage = /^\d+$/.test(last) && segments.length > 2 + ? segments[segments.length - 2] + : last; + } // Get store code from server-rendered value or URL fallback this.storeCode = window.STORE_CODE || null;