Skip to content

Commit bc90de9

Browse files
committed
fix: navlink investigation
1 parent 9494afa commit bc90de9

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

site/src/components/Sidebar/Sidebar.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { CSSObject, Interpolation, Theme } from "@emotion/react";
33
import { Stack } from "components/Stack/Stack";
44
import { type ClassName, useClassName } from "hooks/useClassName";
55
import type { ElementType, FC, ReactNode } from "react";
6-
import { Link, NavLink } from "react-router-dom";
6+
import { Link, NavLink, useLocation } from "react-router-dom";
77
import { cn } from "utils/cn";
88

99
interface SidebarProps {
@@ -61,6 +61,18 @@ export const SettingsSidebarNavItem: FC<SettingsSidebarNavItemProps> = ({
6161
href,
6262
end,
6363
}) => {
64+
65+
const location = useLocation();
66+
if (end) {
67+
console.log('Current Path:', location.pathname);
68+
console.log('NavLink href:', href);
69+
}
70+
71+
const normalizePath = (path: string) =>
72+
path.endsWith('/') ? path.slice(0, -1) : path;
73+
74+
const isInitiallyActive =
75+
normalizePath(location.pathname) === normalizePath(href);
6476
return (
6577
<NavLink
6678
end={end}
@@ -69,7 +81,7 @@ export const SettingsSidebarNavItem: FC<SettingsSidebarNavItemProps> = ({
6981
cn(
7082
"relative text-sm text-content-secondary no-underline font-medium py-2 px-3 hover:bg-surface-secondary rounded-md transition ease-in-out duration-150",
7183
{
72-
"font-semibold text-content-primary": isActive,
84+
"font-semibold text-content-primary": isActive || isInitiallyActive,
7385
},
7486
)
7587
}

0 commit comments

Comments
 (0)