Skip to content

Commit

Permalink
HPCC-32601 ECL Watch v9 fix disappearing subnavigation
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jeclrsg committed Sep 6, 2024
1 parent c8117d4 commit 065f3be
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions esp/src/src-react/components/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 065f3be

Please sign in to comment.