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] - Input component unresponsive to updates to value via ref #3024

Open
cnfw opened this issue May 18, 2024 · 1 comment
Open

[BUG] - Input component unresponsive to updates to value via ref #3024

cnfw opened this issue May 18, 2024 · 1 comment
Assignees
Labels
📦 Scope : Components Related to the components 🐛 Type: Bug Something isn't working

Comments

@cnfw
Copy link

cnfw commented May 18, 2024

NextUI Version

2.3.6

Describe the bug

When modifying an input's value via its ref (i.e. how react-hook-form passes updates to components when the imperative setValue function is used), the input doesn't respond to the change.

I guess that RHF does something like ref.current.value = "new value", so I have also provided an example in the StackBlitz project.

Without digging into the internals of the NextUI component, I'm guessing it creates a controlled input, making it incompatible with an uncontrolled form library.

Your Example Website or App

https://stackblitz.com/edit/vitejs-vite-vnrckd?file=src%2FApp.tsx

Steps to Reproduce the Bug or Issue

  1. Go to https://stackblitz.com/edit/vitejs-vite-vnrckd?file=src%2FApp.tsx
  2. Observe the value in input and the printed value above and below the button.
  3. Click the button.
  4. Observe the printed value updates but the input value remains unchanged.
  5. (Change the input value to observe the original value restored)the

Expected behavior

I expect the value of the input to change to track the form state.

Screenshots or Videos

No response

Operating System Version

Linux

Browser

Chrome

Copy link

linear bot commented May 18, 2024

@wingkwong wingkwong added 🐛 Type: Bug Something isn't working 📦 Scope : Components Related to the components labels May 19, 2024
@wingkwong wingkwong self-assigned this May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 Scope : Components Related to the components 🐛 Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants