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.53k stars 2.08k forks source link

issue: UI not refreshing after validation trigger #12376

Open maniekpl00 opened 1 week ago

maniekpl00 commented 1 week ago

Version Number

7.52.2

Codesandbox/Expo snack

https://codesandbox.io/p/sandbox/clever-phoebe-gsxx7s?workspaceId=e3d19873-74be-401c-9ed5-b17a082e3cec

Steps to reproduce

  1. Click Submit to trigger validation
  2. See error that user name require Minimum 4 chars
  3. Disable field by unchecking Enable user

Expected behaviour

After updating to version 7.52.2, the validation error message for 'Minimum 4 Characters' does not clear as expected.

Previously, the UI would refresh correctly after manually triggering validation based on another field, but this functionality has been disrupted in the latest version. Calling trigger require now to put exact field name to have refreshed UI, which is inconvenient when field has a lot of input forms inside.

It can be related to changes inside useController, that useFormState use exact prop now.

What browsers are you seeing the problem on?

Firefox, Chrome, Safari, Edge

Relevant log output

No response

Code of Conduct

maniekpl00 commented 1 week ago

It seems when I wrap field name into array trigger([`users.${index}`]) to re-trigger the entire form state it works. But question is if it was intentional and even if yes, this release broke old API in same major version 😃

image