Skip to content

form.setFieldValue on an un-initialized field will create meta missing errors #1078

Open
@sinuheshinbr

Description

@sinuheshinbr

Describe the bug

If you have a field that is displayed conditionally in the form, and use form.setFieldValue without dontUpdateMeta: true before it's initialization, it will create meta for this field without errors. I understand that makes more sense to update the value with dontUpdateMeta: true if the field wasn't initialized yet, but it can lead to some inconsistent behavior since we are not expecting errors to be undefined.

Your minimal, reproducible example

https://codesandbox.io/p/github/sinuheshinbr/tanstack-form-missing-errors/main?workspaceId=ws_NWHNzLQ8YDitxFDjr6vrpe

Steps to reproduce

go to: https://codesandbox.io/p/github/sinuheshinbr/tanstack-form-missing-errors/main?workspaceId=ws_NWHNzLQ8YDitxFDjr6vrpe
click on "setFieldValue"
then clikc on "Show"

Expected behavior

After clicking on setFieldValue meta shold include errors array even before the element initialization

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

OS: Manjaro Linux
Browser: Chrome
Version: 129.0.6668.100

TanStack Form adapter

react-form

TanStack Form version

0.40.2

TypeScript version

5.5.3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions