Skip to content

Commit a74e55c

Browse files
authored
🐛 Fixed mobile admin nav bar reloading admin and its dark-mode active state (#28609)
no ref Some tweaks to improve the mobile Admin experience, particularly in dark mode.
1 parent f32d3b4 commit a74e55c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

apps/admin/src/layout/app-sidebar/mobile-nav-bar.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ interface MobileNavBarButtonProps extends Omit<React.ComponentProps<typeof Butto
1313

1414
function MobileNavBarButton({ to, activeOnSubpath = false, children, ...props }: MobileNavBarButtonProps) {
1515
const isActive = useIsActiveLink({ path: to, activeOnSubpath });
16+
// Use a hash route (e.g. "#/posts") so navigation stays client-side; a bare
17+
// relative href like "posts" triggers a full page load and reloads all of admin.
18+
const href = `#/${to?.replace(/^\/?#\//, '')}`;
1619

1720
return (
1821
<Button
1922
asChild
20-
className={`w-full max-w-16 min-w-9 rounded-full hover:bg-gray-200 ${isActive ? 'bg-gray-200' : 'bg-transparent'}`} {...props}
23+
className={`w-full max-w-16 min-w-9 rounded-full hover:bg-sidebar-accent hover:text-sidebar-accent-foreground ${isActive ? 'bg-sidebar-accent text-sidebar-accent-foreground' : 'bg-transparent'}`} {...props}
2124
variant="ghost"
2225
size="icon"
2326
data-active={isActive}
2427
>
25-
<a href={to}>
28+
<a href={href}>
2629
{children}
2730
</a>
2831
</Button>

0 commit comments

Comments
 (0)