Skip to content

Commit

Permalink
ui: Fix selected tab hightlights
Browse files Browse the repository at this point in the history
  • Loading branch information
JBWatenbergScality committed Feb 11, 2025
1 parent 7ec770f commit d8f5065
Showing 1 changed file with 3 additions and 26 deletions.
29 changes: 3 additions & 26 deletions shell-ui/src/navbar/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,30 +122,6 @@ const Link = ({
);
};

function prefetch(url: string) {
return new Promise((resolve, reject) => {
const existingElement = [
...(document.head?.querySelectorAll('script') || []),
// @ts-expect-error - FIXME when you are working on it
].find((scriptElement) => scriptElement.attributes.src?.value === url);

if (existingElement) {
// @ts-expect-error - FIXME when you are working on it
resolve();
}

const script = document.createElement('script');
script.src = url;
script.async = true;
script.onload = (evt) => {
script.setAttribute('data-loaded', 'true');
resolve(evt);
};
script.onerror = reject;
document.head?.appendChild(script);
});
}

export const useNavbarLinksToActions = (
links: TypeLink[],
): {
Expand All @@ -154,8 +130,8 @@ export const useNavbarLinksToActions = (
}[] => {
const location = useLocation();
const doesRouteMatch = useCallback(
(path: RouteProps) => {
return matchPath(path.path + '*', location.pathname);
({ path, exact }: { path: string; exact: boolean }) => {
return matchPath(path + (exact ? '' : '*'), location.pathname);
},
[location],
);
Expand All @@ -181,6 +157,7 @@ export const useNavbarLinksToActions = (
.find((link) =>
link.view.isFederated
? doesRouteMatch({
exact: link.view.view.exact,
path: link.view.view.activeIfMatches
? new RegExp(
link.view.app.appHistoryBasePath +
Expand Down

0 comments on commit d8f5065

Please sign in to comment.