@@ -3,7 +3,7 @@ import type { CSSObject, Interpolation, Theme } from "@emotion/react";
3
3
import { Stack } from "components/Stack/Stack" ;
4
4
import { type ClassName , useClassName } from "hooks/useClassName" ;
5
5
import type { ElementType , FC , ReactNode } from "react" ;
6
- import { Link , NavLink , useLocation } from "react-router-dom" ;
6
+ import { Link , NavLink , useMatch } from "react-router-dom" ;
7
7
import { cn } from "utils/cn" ;
8
8
9
9
interface SidebarProps {
@@ -61,18 +61,8 @@ export const SettingsSidebarNavItem: FC<SettingsSidebarNavItemProps> = ({
61
61
href,
62
62
end,
63
63
} ) => {
64
+ const matchResult = useMatch ( href ) ;
64
65
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 ) ;
76
66
return (
77
67
< NavLink
78
68
end = { end }
@@ -81,7 +71,7 @@ export const SettingsSidebarNavItem: FC<SettingsSidebarNavItemProps> = ({
81
71
cn (
82
72
"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" ,
83
73
{
84
- "font-semibold text-content-primary" : isActive || isInitiallyActive ,
74
+ "font-semibold text-content-primary" : matchResult !== null ,
85
75
} ,
86
76
)
87
77
}
0 commit comments