From 716a4e3d15f73ce838939d218785a09e92f1d893 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Sun, 22 Feb 2026 23:08:17 +0100 Subject: [PATCH] fix: sidebar highlight on detail pages with numeric IDs When visiting /merchants/billing/subscriptions/3, currentPage was set to '3' instead of 'subscriptions'. Now skips numeric trailing segments so the parent page stays highlighted. Applied to both merchant and store init-alpine.js. Co-Authored-By: Claude Opus 4.6 --- app/modules/core/static/merchant/js/init-alpine.js | 6 +++++- app/modules/core/static/store/js/init-alpine.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/modules/core/static/merchant/js/init-alpine.js b/app/modules/core/static/merchant/js/init-alpine.js index 67d93920..8dc416ee 100644 --- a/app/modules/core/static/merchant/js/init-alpine.js +++ b/app/modules/core/static/merchant/js/init-alpine.js @@ -54,7 +54,11 @@ function data() { const segments = path.split('/').filter(Boolean); // For /merchants/dashboard -> 'dashboard' // For /merchants/billing/subscriptions -> 'subscriptions' - this.currentPage = segments[segments.length - 1] || 'dashboard'; + // For /merchants/billing/subscriptions/3 -> 'subscriptions' (skip numeric IDs) + const last = segments[segments.length - 1] || 'dashboard'; + this.currentPage = /^\d+$/.test(last) && segments.length > 2 + ? segments[segments.length - 2] + : last; // Load merchant name from JWT token const token = localStorage.getItem('merchant_token'); diff --git a/app/modules/core/static/store/js/init-alpine.js b/app/modules/core/static/store/js/init-alpine.js index 2d6150ff..1f52e3a9 100644 --- a/app/modules/core/static/store/js/init-alpine.js +++ b/app/modules/core/static/store/js/init-alpine.js @@ -58,7 +58,11 @@ function data() { // Set current page from URL const path = window.location.pathname; const segments = path.split('/').filter(Boolean); - this.currentPage = segments[segments.length - 1] || 'dashboard'; + // 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 URL if (segments[0] === 'store' && segments[1]) {