devtools icon indicating copy to clipboard operation
devtools copied to clipboard

[Bug]: Regression bug generated by releases v7.15.3 (Form Reset)

Open msalahz opened this issue 4 years ago • 6 comments

Version Number

7.15.3

Codesandbox/Expo snack

https://codesandbox.io/s/eloquent-breeze-gywwy?file=/src/Form.tsx

Steps to reproduce

Scenario 1

  1. Enter any string in the first name field
  2. Click on the reset button
  3. Enter any string in the last name field
  4. Check the dev tool Actual: you should find both first & last names fields isDirty equals tor true

Scenario 2

  1. Enter any string in the first name field
  2. Enter any string in the last name field
  3. Click on the Save button (note that I reset the form with newly saved data after save)
  4. Change the value in the first name field
  5. Check the dev tool Actual: you should find both fields has isDirty as false

Expected behaviour

Scenario 1 Expected: you should find only the last name field isDirty equals tor true

Scenario 2 Expected: you should find the first name field isDirty equals tor true

What browsers are you seeing the problem on?

Chrome

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

msalahz avatar Sep 18 '21 19:09 msalahz

I want to add that this issue can be reproduced by any release from v7.8.0 to v7.15.3 and to avoid it I had to fall back to v7.7.1 Here is a fork of the issue sandbox bosted above but with correct behaviors https://codesandbox.io/s/react-hook-form-reset-7-7-1-98hh2

msalahz avatar Sep 18 '21 19:09 msalahz

@bluebill1049 : Why this ticket was moved here? If you checked this sandbox you should find form state returned form useFormState also show the same state issues on v7.8.0

msalahz avatar Sep 19 '21 11:09 msalahz

Check the dev tool Actual: you should find both first & last names fields isDirty equals tor true

bluebill1049 avatar Sep 19 '21 11:09 bluebill1049

please remove the dev tool and all the other dependencies if this issue is related to the core lib, I just did a quick test with your description above and it works.

Screen Shot 2021-09-19 at 9 10 29 pm

update your codesandbox i will take a look at again if its an issue to the core lib or dev tool

bluebill1049 avatar Sep 19 '21 11:09 bluebill1049

Hi @bluebill1049 : I removed the devtool & tried and I couldn't reproduce these issues anymore, Why the devtools could effect the core functionality for the library?

msalahz avatar Sep 20 '21 10:09 msalahz

i suspect it's a bug in the dev tool.

bluebill1049 avatar Sep 20 '21 10:09 bluebill1049