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] - useLink overwrites router-ized prop #4624

Open
jprosevear opened this issue Jan 22, 2025 · 2 comments · May be fixed by #4628
Open

[BUG] - useLink overwrites router-ized prop #4624

jprosevear opened this issue Jan 22, 2025 · 2 comments · May be fixed by #4628
Assignees

Comments

@jprosevear
Copy link

jprosevear commented Jan 22, 2025

HeroUI Version

2.6.13

Describe the bug

This is my current theory as to why my links in RR with useHref are not working:

  1. useLink calls useAriaLink()
  2. useAriaLink calls useLinkProps from react-aria
  3. useLinkProps will use useHref to change the href prop and send it back to useAriaLink
  4. useAriaLink passes back to useLink
  5. useLink does a mergeProps with the original props ('otherProps') after linkProps
    ...mergeProps(focusProps, linkProps, otherProps),
    - overwriting the useHref'ed href

This can be seen as the relative link is "bare" (ie does not have the rest of the route path that a plain useHref locally would show)

ie const href = useHref("blogs") would return '1/blogs' in my case, but stays as "blogs" in the element href

This breaks all relative link navigations for me.

Your Example Website or App

https://stackblitz.com/edit/wfdcu9f2

Steps to Reproduce the Bug or Issue

React Router setup with HeroUIProvider (navigation and href); try relative links. I have a complex setup I can demonstrate on a screenshare if necessary.

Expected behavior

Relative links work

Screenshots or Videos

No response

Operating System Version

macOS

Browser

Chrome

Copy link

linear bot commented Jan 22, 2025

@jprosevear
Copy link
Author

jprosevear commented Jan 22, 2025

I think perhaps otherProps should be dropped entirely from the mergeProps call or moved to the front of the queue

@jprosevear jprosevear linked a pull request Jan 23, 2025 that will close this issue
@wingkwong wingkwong self-assigned this Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants