-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix: routerized links #4628
base: canary
Are you sure you want to change the base?
fix: routerized links #4628
Conversation
|
@jprosevear is attempting to deploy a commit to the HeroUI Inc Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe pull request addresses a bug in the link component's handling of the Changes
Assessment against linked issues
The changes directly address the issue by ensuring that router-generated 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (2)
🔇 Additional comments (5)
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
@@ -110,6 +112,8 @@ export function useLink(originalProps: UseLinkProps) { | |||
"data-focus": dataAttr(isFocused), | |||
"data-disabled": dataAttr(originalProps.isDisabled), | |||
"data-focus-visible": dataAttr(isFocusVisible), | |||
// The `href` prop may be routerized by useAriaLink, so we may merge over top of it | |||
href, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sure that the href on the is set properly
) { | ||
e.preventDefault(); | ||
router.open(e.currentTarget, e, props.href, props.routerOptions); | ||
router.open(e.currentTarget, e, routerLinkProps.href, props.routerOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sure that we use the useHref'ed href for the navigation
may revisit this PR again after #4611 |
Closes #4624
📝 Description
Use the routerized href if available for both the onClick event and the href prop on the element
⛳️ Current behavior (updates)
Currently the original href is used (ignoring the application of useHref) on the onClick and so navigate() for react-router acts on the wrong href and fails for relative links. So if you are at /blogs already and you put href="14" it will try to go to /14 instead of /blogs/14 and the href is decorate with href="14"
🚀 New behavior
navigate() for react-router works, going to /blogs/14 and the element is decorated correctly (/blogs/14) .
💣 Is this a breaking change (Yes/No):
Possible, but I don't think it worked before with relative links in RR; absolute links should still work.
📝 Additional Information
Summary by CodeRabbit
Improvements
href
handlingautoFocus
,isExternal
, andshowAnchorIcon
propertiesAccessibility