@@ -62,7 +62,7 @@ const AdminNavItems = ({ toggleMobileNav }: Props) => {
6262 {
6363 name : "Analytics" ,
6464 href : `/dashboard/analytics` ,
65- exactMatch : true ,
65+ matchChildren : true ,
6666 icon : < ChartLineIcon /> ,
6767 subNav : [ ] ,
6868 } ,
@@ -91,8 +91,13 @@ const AdminNavItems = ({ toggleMobileNav }: Props) => {
9191 const [ openAIDialog , setOpenAIDialog ] = useState ( false ) ;
9292 const router = useRouter ( ) ;
9393
94- const isPathActive = ( path : string , exactMatch : boolean = false ) =>
95- exactMatch ? pathname === path : pathname . includes ( path ) ;
94+ const isPathActive = ( path : string , matchChildren : boolean = false ) => {
95+ if ( matchChildren ) {
96+ return pathname === path || pathname . startsWith ( `${ path } /` ) ;
97+ }
98+
99+ return pathname === path ;
100+ } ;
96101
97102 const isDomainSetupVerified =
98103 activeOrg ?. organization . customDomain &&
@@ -282,7 +287,7 @@ const AdminNavItems = ({ toggleMobileNav }: Props) => {
282287 key = { item . name }
283288 className = "flex relative justify-center items-center mb-1.5 w-full"
284289 >
285- { isPathActive ( item . href , item . exactMatch ?? false ) && (
290+ { isPathActive ( item . href , item . matchChildren ?? false ) && (
286291 < motion . div
287292 animate = { {
288293 width : sidebarCollapsed ? 36 : "100%" ,
@@ -311,7 +316,7 @@ const AdminNavItems = ({ toggleMobileNav }: Props) => {
311316 toggleMobileNav = { toggleMobileNav }
312317 isPathActive = { isPathActive }
313318 extraText = { item . extraText }
314- exactMatch = { item . exactMatch ?? false }
319+ matchChildren = { item . matchChildren ?? false }
315320 />
316321 </ div >
317322 ) ) }
@@ -401,7 +406,7 @@ const NavItem = ({
401406 sidebarCollapsed,
402407 toggleMobileNav,
403408 isPathActive,
404- exactMatch ,
409+ matchChildren ,
405410 extraText,
406411} : {
407412 name : string ;
@@ -413,9 +418,9 @@ const NavItem = ({
413418 } > ;
414419 sidebarCollapsed : boolean ;
415420 toggleMobileNav ?: ( ) => void ;
416- isPathActive : ( path : string , exactMatch : boolean ) => boolean ;
421+ isPathActive : ( path : string , matchChildren : boolean ) => boolean ;
417422 extraText : number | null | undefined ;
418- exactMatch : boolean ;
423+ matchChildren : boolean ;
419424} ) => {
420425 const iconRef = useRef < CogIconHandle > ( null ) ;
421426 return (
@@ -436,7 +441,7 @@ const NavItem = ({
436441 sidebarCollapsed
437442 ? "flex justify-center items-center px-0 w-full size-9"
438443 : "px-3 py-2 w-full" ,
439- isPathActive ( href , exactMatch )
444+ isPathActive ( href , matchChildren )
440445 ? "bg-transparent pointer-events-none"
441446 : "hover:bg-gray-2" ,
442447 "flex overflow-hidden justify-start items-center tracking-tight rounded-xl outline-none" ,
0 commit comments