[BUG] - Input don't add defaultValue in uncontrolled Input after form submit
NextUI Version
2.6.8
Describe the bug
After submitting an form and there are validation errors the response will put back input value using defaultValue prop. Following this video. When using NextUI Input component it clears no matter what. Using native input it works (or shadcn/ui as in video).
Your Example Website or App
https://codesandbox.io/p/devbox/nk4vk2
Steps to Reproduce the Bug or Issue
Start the project and test both the inputs
Expected behavior
That the default value to be set as with the native input
Screenshots or Videos
No response
Operating System Version
Window 11
Browser
Chrome
A form reset happens when the form action property is used in this way. If you want to keep this form reset behavior, then this is an issue with RAC (see adobe/react-spectrum#6830). For potential ways to opt-out of the reset and still use React 19 hooks, see the discussion of the root issue.
A form reset happens when the form
actionproperty is used in this way. If you want to keep this form reset behavior, then this is an issue with RAC (see adobe/react-spectrum#6830). For potential ways to opt-out of the reset and still use React 19 hooks, see the discussion of the root issue.
Thanks for pointing me in the right direction ✌️. Not a big fan of the workarround tough, using onSubmit over action.
Thanks again!
Happy holidays 🎅🎆!
A form reset happens when the form
actionproperty is used in this way. If you want to keep this form reset behavior, then this is an issue with RAC (see adobe/react-spectrum#6830). For potential ways to opt-out of the reset and still use React 19 hooks, see the discussion of the root issue.
Why can't we use input's defaultValue to set value from state when validation fails on server?
return {
success: false,
inputs: values
}
<Input defaultValue={state.inputs?.email ?? ""} />
Note that it works with native inputs.