Skip to content

Commit

Permalink
fix(chat): broken navigation highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
Mati365 committed Dec 29, 2024
1 parent d6ffa45 commit 129697d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions apps/chat/src/layouts/navigation/links/navigation-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { PropsWithChildren, ReactNode } from 'react';
import clsx from 'clsx';
import { Link, useLocation } from 'wouter';

import { prefixWithBaseRoute } from '~/routes/use-sitemap';

export type NavigationItemProps = PropsWithChildren & {
path: string;
icon: ReactNode;
Expand All @@ -12,9 +14,9 @@ export type NavigationItemProps = PropsWithChildren & {
export function NavigationItem({ path, icon, children, disabled }: NavigationItemProps) {
const [location] = useLocation();
const isActive = (
path !== '/'
? location.startsWith(path)
: location === path
path === prefixWithBaseRoute('/')
? location === path
: location.startsWith(path)
);

return (
Expand Down
4 changes: 2 additions & 2 deletions apps/chat/src/routes/use-sitemap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ export function useSitemap() {
return sitemap;
};

function prefixWithBaseRoute(path: string) {
return concatUrls(import.meta.env.BASE_URL ?? '/', path);
export function prefixWithBaseRoute(path?: string) {
return concatUrls(import.meta.env.BASE_URL ?? '/', path ?? '');
}

0 comments on commit 129697d

Please sign in to comment.