-
-
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(use-aria-link): onclick deprecation warning for Button as Link #4497
Conversation
🦋 Changeset detectedLatest commit: a80d563 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe pull request addresses a deprecation warning for the Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
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
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/hooks/use-aria-link/src/index.ts (1)
22-23
: Ensure therole
property has a well-defined domain of valid values
While adding an optionalrole
property is reasonable, consider using a restricted set of valid roles (e.g., "link", "button") or providing guidance in the docs about its usage to ensure clarity and correctness.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.changeset/sixty-fireants-build.md
(1 hunks)packages/hooks/use-aria-link/src/index.ts
(3 hunks)
🔇 Additional comments (3)
packages/hooks/use-aria-link/src/index.ts (2)
51-51
: Validaterole
in the calling context
Before destructuring therole
prop, you might want to ensure that ifrole
is provided, it matches an expected set of roles. This could help prevent accidental usage of unsupported roles.
67-67
: Well-handled condition for deprecation warning
Restricting the warning to non-button roles is a sound approach. This logic effectively prevents unnecessary warnings for button-like usage. Great job..changeset/sixty-fireants-build.md (1)
1-5
: Accurate changeset description
The changeset succinctly explains the fix for the button-as-link deprecation warning. This documentation will help developers understand why the patch was introduced.
Closes #4493
📝 Description
Users receive
[Next UI] [useLink]: onClick is deprecated, please use onPress instead.
when using<Button as={Link} href="/">
. TheonClick
was introduced fromusePress
internally. ThisonClick
would pass toLink
and trigger that warning. This PR is to handle this case by checking therole
. If using as a polymorphic component, the role will bebutton
.⛳️ Current behavior (updates)
Got
[Next UI] [useLink]: onClick is deprecated, please use onPress instead.
while not defining anyonClick
.🚀 New behavior
No such warning when using
<Button as={Link} href="/">
💣 Is this a breaking change (Yes/No):
📝 Additional Information
Summary by CodeRabbit
Bug Fixes
onClick
event for different element rolesNew Features
role
property to customize element behavior