diff --git a/esp/src/src-react/components/Menu.tsx b/esp/src/src-react/components/Menu.tsx index ad77f8c47d3..2b8fdad4eb8 100644 --- a/esp/src/src-react/components/Menu.tsx +++ b/esp/src/src-react/components/Menu.tsx @@ -4,6 +4,7 @@ import { useConst } from "@fluentui/react-hooks"; import nlsHPCC from "src/nlsHPCC"; import { hasLogAccess } from "src/ESPLog"; import { containerized, bare_metal } from "src/BuildInfo"; +import { navCategory } from "../util/history"; import { MainNav, routes } from "../routes"; import { useFavorite, useFavorites, useHistory } from "../hooks/favorite"; import { useSessionStore } from "../hooks/store"; @@ -98,7 +99,7 @@ routes.forEach((route: any) => { }); function navSelectedKey(hashPath) { - const rootPath = navIdx(`/${hashPath?.split("/")[1]}`); + const rootPath = navIdx(`/${navCategory(hashPath)?.split("/")[1]}`); if (rootPath?.length) { return rootPath[0]; } @@ -214,8 +215,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 { diff --git a/esp/src/src-react/util/history.ts b/esp/src/src-react/util/history.ts index d4420fc4d7e..6f54845db45 100644 --- a/esp/src/src-react/util/history.ts +++ b/esp/src/src-react/util/history.ts @@ -278,3 +278,11 @@ export function updateState(key: string, val?: string | string[] | number | bool } globalHistory.replaceState(state, ""); } + +export function navCategory(hash: string): string { + let category = hash.split("/").slice(0, 2).join("/"); + if (category.indexOf("?") > -1) { + category = category.substring(0, category.indexOf("?")); + } + return category; +} \ No newline at end of file