Skip to content
Source
Sign inSign up
TanStack/form

`evaluate` does not correctly compare objects which breaks formOptions updates #1628

Send to my agent
Closedtcgj(GitHub profile, opens in a new tab) opened this issue 3 comments

Describe the bug

This is essentially the same issue as https://github.com/TanStack/store/issues/218, but specific to useForm's form options updates. If default values were changed and the changed value is an object that does not return property keys via Object.keys—such as Date, File, or Temporal.Duration/Temporal.PlainDate—then evaluate returns true and shouldUpdateValues returns false. This causes the form API to not be updated, so nothing rerenders despite a prop change.

Your minimal, reproducible example

https://codesandbox.io/p/devbox/modest-jang-4635xz

Steps to reproduce

  1. Create a field that uses one of these types of objects as a value. e.g. Temporal.Duration, or Date.
  2. Give it a default value
  3. Update the default value (without touching the input)

Expected behavior

The field should update its untouched default value accordingly to the updated default value.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Arc (Chromium)
  • Version: 138.0

TanStack Form adapter

react-form

TanStack Form version

v1.12.3

TypeScript version

v5.8.2

Additional context

No response

  1. Might want to reference for this update to shallow for evaluate.

    https://github.com/TanStack/store/pull/222

  2. Wondering if there is any progress on this, or general guidance on how to use a form that has field values that are a Date or Temporal? Field state values not being reliably updated here definitely causes unexpected behavior.

  3. In lieu of direct Temporal support, it might be nice to have a general mechanism for either supporting a custom comparator, or looking for a special object._tanstackComparisonValue() on objects. Then at least we could patch the Temporal prototypes with that.

Sign in to join this conversation.