Skip to content

Commit

Permalink
Fix elie222#201: Active class for sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
madhav-relish committed Aug 28, 2024
1 parent 10ac3ee commit 7910318
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions apps/web/components/SideNav.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { Fragment } from "react";
import { usePathname } from "next/navigation";
import { usePathname, useSearchParams } from "next/navigation";
import Link from "next/link";
import {
Dialog,
Expand Down Expand Up @@ -297,6 +297,8 @@ export function SideNav(props: {

function Sidebar(props: { isMobile: boolean }) {
const path = usePathname();
const searchParams = useSearchParams();
const activePath = "?" + searchParams.toString(); // "?" is added to match the href strings of NavItems
const showMailNav = path === "/mail" || path === "/compose";

const { onOpen } = useComposeModal();
Expand Down Expand Up @@ -332,12 +334,12 @@ function Sidebar(props: { isMobile: boolean }) {
</Button>

<div className="mt-2">
<Links path={path} links={topMailLinks} />
<Links path={activePath} links={topMailLinks} />
</div>
<div className="mt-7">
<NavSectionHeader title="Labels" />
<div className="mt-2">
<Links path={path} links={bottomMailLinks} />
<Links path={activePath} links={bottomMailLinks} />
</div>
</div>
</Transition>
Expand Down

0 comments on commit 7910318

Please sign in to comment.