form icon indicating copy to clipboard operation
form copied to clipboard

validateAllFields immediately after form.reset doesn't work

Open jashworth opened this issue 9 months ago • 2 comments

Describe the bug

form.validateAllFields (line 130) does not appear to revalidate the fields after form.reset({ ... })

...at least not synchronously (see lines 133-135)

Your minimal, reproducible example

https://codesandbox.io/p/devbox/fervent-ives-32x45k

Steps to reproduce

  1. Observe the initial error ("must not be before 2025-06-02") in the Run Date field of the form
  2. Select the "Dead" radio button
  3. Select the "Once" radio button
  4. Observe the date is the same as before but the error has gone, despite the call to form.validateAllFields (line 130)

Expected behavior

form.validateAllFields (line 130) revalidates all fields, resulting in the error being displayed

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Windows Chrome (latest)

TanStack Form adapter

react-form

TanStack Form version

1.90.0

TypeScript version

5.7.2

Additional context

The aim is to use form.reset({ ... }) to set multiple co-variant fields together, revealing any constraint violations to the user as soon as the values have been set.

Is there an alternative way to revalidate after reset, preferably one that doesn't rerender the entire component?

jashworth avatar May 07 '25 11:05 jashworth

@jashworth I think you've left your codeSandbox as private, as clicking the link provided doesn’t open one 😅

I haven't looked but do you think this could be related to #1485, if you could do a little investigation it would help us out a bunch 😄 if not we will take a look when we get some time!

harry-whorlow avatar May 07 '25 21:05 harry-whorlow

Oops!

is public now

jashworth avatar May 08 '25 07:05 jashworth