Skip to content

ref(nav) move isLinkActive and ProjectIcon inside components#110372

Merged
JonasBa merged 2 commits intojb/ref/navigation/naming-navfrom
jb/ref/nav-islinkactive
Mar 11, 2026
Merged

ref(nav) move isLinkActive and ProjectIcon inside components#110372
JonasBa merged 2 commits intojb/ref/navigation/naming-navfrom
jb/ref/nav-islinkactive

Conversation

@JonasBa
Copy link
Member

@JonasBa JonasBa commented Mar 10, 2026

Moves ProjectIcon inside Secondary Nav components, moves prop definitions next to component implementations and moves isLinkActive inside the primary nav component.

@JonasBa JonasBa requested a review from malwilley March 10, 2026 22:01
@JonasBa JonasBa requested review from a team as code owners March 10, 2026 22:01
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 10, 2026
@JonasBa JonasBa requested a review from a team March 10, 2026 22:10
@@ -1,17 +0,0 @@
import type {To} from '@remix-run/router';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@malwilley I've changed this to LocationDescriptor, but lmk if it was intentional and should be preserved

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not intentional!

Comment on lines +518 to +522
export function isSidebarLinkActive(
to: LocationDescriptor | string,
pathname: string,
options: {end?: boolean} = {end: false}
): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The isSidebarLinkActive function normalizes the to path but not the pathname argument. This causes the active state check to fail for secondary navigation links.
Severity: MEDIUM

Suggested Fix

Normalize the pathname argument inside the isSidebarLinkActive function, similar to how the to argument is normalized. This will ensure both paths are compared in the same format, fixing the active state logic for secondary navigation.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: static/app/views/navigation/primary/components.tsx#L518-L522

Potential issue: The refactored `isSidebarLinkActive` function is used for both primary
and secondary navigation. For secondary navigation, it's called with a `pathname` that
includes the full URL path (e.g., `/organizations/org-slug/...`). However, the function
only normalizes its `to` argument, stripping prefixes like the organization slug. It
then compares the un-normalized `pathname` with the normalized `to` path using
`pathname.startsWith(toPathname)`. This comparison will always fail when an organization
slug is present, preventing secondary navigation links from being highlighted as active.

Did we get this right? 👍 / 👎 to inform future reviews.

@JonasBa JonasBa merged commit bc3f137 into jb/ref/navigation/naming-nav Mar 11, 2026
63 of 65 checks passed
@JonasBa JonasBa deleted the jb/ref/nav-islinkactive branch March 11, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants