From 065f3be61548d50fb116455e9a5c43ade4b6773c Mon Sep 17 00:00:00 2001 From: Jeremy Clements <79224539+jeclrsg@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:19:33 -0400 Subject: [PATCH] HPCC-32601 ECL Watch v9 fix disappearing subnavigation fixes an issue where the subnavigation would not display properly on page load if a query-string existed in the url Signed-off-by: Jeremy Clements <79224539+jeclrsg@users.noreply.github.com> --- esp/src/src-react/components/Menu.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/esp/src/src-react/components/Menu.tsx b/esp/src/src-react/components/Menu.tsx index ad77f8c47d3..355dc8f4bd0 100644 --- a/esp/src/src-react/components/Menu.tsx +++ b/esp/src/src-react/components/Menu.tsx @@ -97,8 +97,16 @@ routes.forEach((route: any) => { } }); +function navCategory(hash) { + let category = hash.split("/").slice(0, 2).join("/"); + if (category.indexOf("?") > -1) { + category = category.substring(0, category.indexOf("?")); + } + return category; +} + function navSelectedKey(hashPath) { - const rootPath = navIdx(`/${hashPath?.split("/")[1]}`); + const rootPath = navIdx(`/${navCategory(hashPath)?.split("/")[1]}`); if (rootPath?.length) { return rootPath[0]; } @@ -214,8 +222,8 @@ for (const key in subMenuItems) { } function subNavSelectedKey(hashPath) { - const hashCategory = hashPath.split("/").slice(0, 3).join("/"); - return subNavIdx(hashCategory).length ? hashCategory : null; + const category = navCategory(hashPath); + return subNavIdx(category).length ? category : null; } interface SubNavigationProps {