question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reset forces all fields to be changed

See original GitHub issue

Describe the bug When using {mode: 'onChange'} with validations, reset() sets isValid as false but now it enforces all the fields to be changed to set isValid as true

To Reproduce Steps to reproduce the behavior:

  1. Go to the sandbox below
  2. Notice that isValid is true
  3. Click on RESET button (now isValid is false)
  4. Change just one input value
  5. Notice that isValid is still false
  6. Click on VALIDATE or change the other input value (now isValid is true)

Codesandbox link https://codesandbox.io/s/react-hook-form-reset-forces-all-fields-to-be-changed-p9q8v

Expected behavior After calling reset() with default values we can do two different things:

  1. If default values fulfill form validations isValid should be true.
  2. If default values fulfill form validations as soon as one input changes to a still valid value isValid should be true. If you agree that this is a bug decide which one of the above solutions is better and makes more sense.

Desktop (please complete the following information):

  • OS: macOS Catalina Version 10.15.1
  • Browser: Google Chrome Version 78.0.3904.108 (Official Build) (64-bit)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
MatiasCicconecommented, Nov 22, 2019

@bluebill1049 please take a look again to the sandbox I updated it with your suggestions. And isValid is not true until I execute triggerValidation or I change all the inputs. Take into consideration that this happens only if you first execute reset https://codesandbox.io/s/react-hook-form-reset-forces-all-fields-to-be-changed-p9q8v

1reaction
bluebill1049commented, Nov 22, 2019

that’s fine @krnlde 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Force field to become blank based on another field's value
Then use this code in the OnChange property of Report type to conditionally reset the Published dropdown when the value selected is 'Data ......
Read more >
useForm - reset - React Hook Form
Reset the entire form state, fields reference, and subscriptions. There are optional arguments and will allow partial form state reset.
Read more >
Resetting a multi-stage form with jQuery - Stack Overflow
resetValue(); // reset all fields in a certain container $( "#someContainer :input" ).resetValue(); // reset all fields $( ":input" ).resetValue ...
Read more >
How do I reset/restart an auto number field automatically?
I want to reset/restart an auto number field automatically every month. How do I reset/restart automatically? ... 3. Click "Change Field Type" and ......
Read more >
After Displaying Alert on Field Change reset the checkbox
Created a check box: Display_Alert__c default 'False' · Created a Record Triggered Flow that checks for isChange(Field__c) and sets the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found