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(input): isClearable & add test cases to input #2796
Conversation
🦋 Changeset detectedLatest commit: fde03c2 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 ↗︎
|
WalkthroughThis update addresses a bug in the NextUI Changes
Assessment against linked issues
The changes effectively address the core issue of the clear button not working as expected by adjusting the component's internal handling of input clearing and state management. The addition of Recent Review DetailsConfiguration used: .coderabbit.yaml Files selected for processing (1)
Files skipped from review as they are similar to previous changes (1)
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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: 1
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: 1
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.
Looks good overall! I've left some comments on a few points.
Updating the input value for React Hook Form actually introduces breaking changes. Previously, it would function with RHF's ASYNC default values because, as you mentioned, RHF uses ref.value. However, the value is now overwritten due to setInputValue being called first, which sets it to initial ref.value. As a result, async values come back, and RHF updates ref.value. However, NextUI's input state is already set so changing ref.value only reflects changes temporarily (and for input only), NextUI will use its own input state value. Visual example: Workarounds:
|
Closes #2791
📝 Description
useSafeLayoutEffect
to handle react-hook-form case. consistent with others⛳️ Current behavior (updates)
with
isClearable
, users fail to clear the value due to the previous change🚀 New behavior
with
isClearable
, users are able to clear the value.pr2796-demo.webm
💣 Is this a breaking change (Yes/No):
No
📝 Additional Information
Summary by CodeRabbit
New Features
isClearable
option.WithReactHookForm
component for better form handling and validation usingreact-hook-form
.Bug Fixes
Tests
onClear
callback correctly.Dependencies
react-hook-form
to improve form state management and validation.