Skip to content

isDirty should flip back to false when default values are equal #1080

Closed
@alexqhj

Description

@alexqhj

Describe the bug

isDirty flips to true when you change any form value, but doesn't return to false when the state returns back to default values.

For most if not all form libraries I've used, the expected behavior is the form is not dirty when the default values is equal. See formik example here:
https://stackblitz.com/edit/react-hooks-form-validation-example-formik-hh9rdieb

Tanstack Form already exposes the isTouched property which can be used to determine if the form has been touched. It appears right now that both isTouched and isDirty now have the same behavior. Except when you reset the form, dirty returns to false as expected.

Your minimal, reproducible example

https://stackblitz.com/edit/tanstack-form-1cspfar1?file=src%2Findex.tsx

Steps to reproduce

  1. Type in to the input
  2. See that the form is dirty
  3. Remove the value from the input
  4. See that the form remains dirty
  5. Reset the form
  6. See that the form is no longer dirty

Expected behavior

  1. Type into the input
  2. See that the form is dirty
  3. Remove the value from the input (effectively resetting it)
  4. See that the form is no longer dirty

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

  • Windows
  • Chrome Version 131.0.6778.140

TanStack Form adapter

None

TanStack Form version

0.40.2

TypeScript version

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions