Keep the Buildings tab highlighted on building detail pages #111

Open
opened 2026-10-03 20:44:39 +00:00 by emmawong · 1 comment
Member

Overall Objective

The Buildings navigation tab is highlighted while a user is on /building-options. However, after the user selects a dorm and moves to a building-details URL such as /building/mudge, the highlight disappears.

The user is still browsing the Buildings section, so the Buildings tab should remain highlighted. Please fix this behavior.

This issue only changes which navigation tab is highlighted.

Suggested Approach

  1. Open apps/frontend/src/components/Navbar.tsx.

  2. Near the beginning of the Navbar component, find:

    const pathname = location.pathname;
    

    The component uses pathname to decide which navigation tab should be highlighted.

  3. Find the two NavButton components named "Buildings". One is used by the desktop navigation bar, and the other is used by the mobile navigation bar.

    They currently contain:

    isActive={pathname === "/building-options"}
    

    This only recognizes the All Buildings page. It does not recognize building-detail URLs such as /building/mudge.

  4. Under const pathname = location.pathname;, create a reusable boolean:

    const isBuildingsActive =
      pathname === "/building-options" || pathname.startsWith("/building/");
    

    Keep the slash at the end of "/building/". Using only pathname.startsWith("/building") would also match /building-comparison, causing two navigation tabs to appear active.

  5. Update both Buildings NavButton components to use the new boolean:

    isActive={isBuildingsActive}
    

    Reuse the same boolean for desktop and mobile so their behavior stays consistent.

Help & Resources

### Overall Objective The **Buildings** navigation tab is highlighted while a user is on `/building-options`. However, after the user selects a dorm and moves to a building-details URL such as `/building/mudge`, the highlight disappears. The user is still browsing the Buildings section, so the Buildings tab should remain highlighted. Please fix this behavior. This issue only changes which navigation tab is highlighted. ### Suggested Approach 1. Open `apps/frontend/src/components/Navbar.tsx`. 2. Near the beginning of the `Navbar` component, find: ```tsx const pathname = location.pathname; ``` The component uses `pathname` to decide which navigation tab should be highlighted. 3. Find the two `NavButton` components named `"Buildings"`. One is used by the desktop navigation bar, and the other is used by the mobile navigation bar. They currently contain: ```tsx isActive={pathname === "/building-options"} ``` This only recognizes the All Buildings page. It does not recognize building-detail URLs such as `/building/mudge`. 4. Under `const pathname = location.pathname;`, create a reusable boolean: ```tsx const isBuildingsActive = pathname === "/building-options" || pathname.startsWith("/building/"); ``` Keep the slash at the end of `"/building/"`. Using only `pathname.startsWith("/building")` would also match `/building-comparison`, causing two navigation tabs to appear active. 5. Update both Buildings `NavButton` components to use the new boolean: ```tsx isActive={isBuildingsActive} ``` Reuse the same boolean for desktop and mobile so their behavior stays consistent. ### Help & Resources - [README](../../ScottyLabs/housing/src/branch/main/README.md) - [Contributing Guidelines](../../ScottyLabs/housing/src/branch/main/docs/CONTRIBUTING.md)
xindiy self-assigned this 2026-10-03 20:51:02 +00:00
Member

No activity here for 21 days. If this is still live, drop a comment or push something and I'll clear the label. Otherwise it'll be unassigned on the next sweep.

No activity here for 21 days. If this is still live, drop a comment or push something and I'll clear the label. Otherwise it'll be unassigned on the next sweep.
Sign in to join this conversation.
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ScottyLabs/housing#111
No description provided.