react-hook-form / react-hook-form

📋 React Hooks for form state management and validation (Web + React Native)
https://react-hook-form.com
MIT License
41.58k stars 2.08k forks source link

issue: Fields dirty state is not updated when passing values to useForm since 7.51.0 #11794

Closed djhi closed 6 months ago

djhi commented 7 months ago

Version Number

7.51.0

Codesandbox/Expo snack

https://codesandbox.io/p/sandbox/control-forked-stnhsf

Steps to reproduce

To reproduce, change the value of the only input and observe the isDirty value displayed by the IsolateReRender component. It stays false

Expected behaviour

It should be set to true.

I actually set up two sandboxes:

The issue is still present in v7.51.3.

This breaks all react-admin applications.

What browsers are you seeing the problem on?

No response

Relevant log output

No response

Code of Conduct

bluebill1049 commented 7 months ago

thanks, for the report, looks like the issue is already fixed: https://codesandbox.io/p/sandbox/control-forked-5fys45?file=%2Fsrc%2FApp.tsx%3A9%2C20 related issue: https://github.com/react-hook-form/react-hook-form/issues/11778

I will release a patch for this soon.

djhi commented 7 months ago

There's something I don't understand though. My second sandbox (https://codesandbox.io/p/sandbox/control-forked-stnhsf) uses 7.51.3 just like yours, yet it has the same issue but yours don't. Besides, I don't see any differences between the two.

slax57 commented 7 months ago

There's something I don't understand though. My second sandbox (https://codesandbox.io/p/sandbox/control-forked-stnhsf) uses 7.51.3 just like yours, yet it has the same issue but yours don't. Besides, I don't see any differences between the two.

That's because the fixed sandbox imports from ./src and not from react-hook-form

djhi commented 6 months ago

There's something I don't understand though. My second sandbox (https://codesandbox.io/p/sandbox/control-forked-stnhsf) uses 7.51.3 just like yours, yet it has the same issue but yours don't. Besides, I don't see any differences between the two.

That's because the fixed sandbox imports from ./src and not from react-hook-form

Good catch, thanks :)

djhi commented 6 months ago

@bluebill1049 Any chance to have a release soon? :pray:

bluebill1049 commented 6 months ago

@bluebill1049 Any chance to have a release soon? 🙏

yes, sorry I am on a break.

djhi commented 6 months ago

Hi @bluebill1049! Thank you for the release. It does not seem to be fixed though :sob: https://codesandbox.io/p/sandbox/control-forked-stnhsf

TheWirv commented 6 months ago

I have breaking unit tests because a CSS class is applied based on the isDirty state, and I check in the tests, whether the class is applied or not.

I have logged some of the data while rendering the component, and this is the final state, with version 7.51.4: image

I have executed the same test on an older version (I am trying to upgrade package versions for our project right now) and there it works fine, with version 7.15.4: image

Both use the same userEvent.type API from the user event testing library.

Cafnio commented 6 months ago

Also happening in my case. using latest release

Keep up the great work, thanks!

RayzorFlash commented 5 months ago

Can second, still seeing issues with dirty fields on the latest release (7.51.5)

WiXSL commented 4 months ago

Hi @bluebill1049! Thank you for the release. It does not seem to be fixed though 😭 https://codesandbox.io/p/sandbox/control-forked-stnhsf

It seems solved by upgrading rhf to version 7.52.1 in your codesandbox