Skip to content

[react-form] there is no way to clear a form value if it has a default value. #1289

@a-eid

Description

@a-eid

Describe the bug

useForm({
  defaultValues: {
    status: params.get('status') // assume this is active for example 
  }
})
      <form.Field name="status" asyncAlways>
        {(field) => (
        .... 
        field.setValue(undefined) // doesn't work. it resets status to active.
        form.setFieldValue("status", undefined) // doesn't work. it resets status to active.
        field.setValue(undefined) // doesn't work. it resets status to active.
        )}
      </form.Field> 

they all default to the default value

Your minimal, reproducible example

TODO

Steps to reproduce

N/A

Expected behavior

I would expect that setValue / handleChange would accept undefiend and it wouldn't be overridden by the default value.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: Macos
  • version: ^1.0.5

TanStack Form adapter

None

TanStack Form version

^1.0.5

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