Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: NavLink is never active when using relative="path" #9450

Closed
manzano78 opened this issue Oct 12, 2022 · 3 comments · Fixed by #9453
Closed

[Bug]: NavLink is never active when using relative="path" #9450

manzano78 opened this issue Oct 12, 2022 · 3 comments · Fixed by #9453
Labels

Comments

@manzano78
Copy link
Contributor

manzano78 commented Oct 12, 2022

What version of React Router are you using?

6.4.2

Steps to Reproduce

  1. Create a data router with one route configured with this path: /contact/:id
  2. In that route's element, render a relative="path" NavLink:
    <NavLink relative="path" to="../1" className={({ isActive }) => isActive ? "active" : undefined} >Michael</NavLink>
  3. In your browser, go to the following URL: /contact/1

Expected Behavior

The generated DOM element should contain the active class: <a href="/contact/1" class="active">Michael</a>

Actual Behavior

The generated DOM element has the right href but doesn't contain the active class: <a href="/contact/1">Michael</a>, so the expected styles aren't applied.

@kiliman
Copy link
Contributor

kiliman commented Oct 12, 2022

Looks like <NavLink> was not updated to handle <Link relative/>

export const NavLink = React.forwardRef<HTMLAnchorElement, NavLinkProps>(

@brophdawg11
Copy link
Contributor

Merged the fix for this - should be released in a 6.4.3 hopefully later this week 👍

@brophdawg11
Copy link
Contributor

👋 Just did a prerelease (6.4.3-pre.0) which should fix this if you want to give it a shot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants