Reset one field resetting the whole form
See original GitHub issueHello,
Describe the bug My understanding is reset can be used to reset one field only (while keeping other dirty ones as they are)
Simple scenario: 2 drop downs (state & city). I want to reset the city
when the state
changes
To Reproduce Steps to reproduce the behavior:
- Go to codesandbox
- Select state/city works fine
- Now uncomment
React.useEffect
- Now try to select a state (nothing will be selected cause the
reset
is resetting the whole form)
Codesandbox link (Required) https://codesandbox.io/s/keen-monad-ddoyc?file=/src/App.tsx:524-621
Expected behavior
reset
to only reset the field(s) provided to it
Screenshots
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How to reset only specific fields of form in angular 5
It works perfectly fine resetting the whole form, but is it possible to just reset some of the elements and keeping other the...
Read more >Reset form - only the specific fields - Power Platform Community
Solved: Hi Experts, I have to reset the form after submitting the form, but not to reset one particular field. Example: I am...
Read more >HTMLFormElement.reset() - Web APIs | MDN
The HTMLFormElement.reset() method restores a form element's default values. This method does the same thing as clicking the form's control.
Read more >HTML DOM Form reset() Method - W3Schools
The reset() method resets the values of all elements in a form (same as clicking the Reset button). Tip: Use the submit() method...
Read more >How to reset or clear a form using JavaScript? - Tutorialspoint
By using the reset method with the variable (which contains the return value of the call to the method) we can reset every...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
csb w/ setValue in case anyone from the internet comes across this in the future: https://codesandbox.io/s/crazy-gates-lkuk8
I ended up using
setValue
instead. Please close if it’s not an issue