From 4e1eb22c8fa5c2295a1c471fd9f0dd47d97ffcf0 Mon Sep 17 00:00:00 2001 From: dwindown Date: Tue, 4 Nov 2025 22:43:20 +0700 Subject: [PATCH] fix: Use parse_request hook for /admin + Dashboard menu now active on Overview (root path) --- admin-spa/src/App.tsx | 4 +++- includes/Admin/StandaloneAdmin.php | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/admin-spa/src/App.tsx b/admin-spa/src/App.tsx index da7d9b5..5d07041 100644 --- a/admin-spa/src/App.tsx +++ b/admin-spa/src/App.tsx @@ -86,7 +86,9 @@ function ActiveNavLink({ to, startsWith, children, className, end }: any) { to={to} end={end} className={(nav) => { - const activeByPath = starts ? location.pathname.startsWith(starts) : false; + // Special case: Dashboard should also match root path "/" + const isDashboard = starts === '/dashboard' && location.pathname === '/'; + const activeByPath = starts ? (location.pathname.startsWith(starts) || isDashboard) : false; const mergedActive = nav.isActive || activeByPath; if (typeof className === 'function') { // Preserve caller pattern: className receives { isActive } diff --git a/includes/Admin/StandaloneAdmin.php b/includes/Admin/StandaloneAdmin.php index 5450d4c..5eeea93 100644 --- a/includes/Admin/StandaloneAdmin.php +++ b/includes/Admin/StandaloneAdmin.php @@ -15,8 +15,8 @@ class StandaloneAdmin { * Initialize standalone admin handler */ public static function init() { - // Catch /admin requests early - add_action( 'template_redirect', [ __CLASS__, 'handle_admin_request' ], 1 ); + // Catch /admin requests very early (before WordPress routing) + add_action( 'parse_request', [ __CLASS__, 'handle_admin_request' ], 1 ); } /**