8000 form.resetFieldValue() doesn't work for nested fields · Issue #1496 · TanStack/form · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
form.resetFieldValue() doesn't work for nested fields #1496
Closed
@LeCarbonator

Description

@LeCarbonator

Describe the bug

When calling form.resetFieldValue() on a nested field ('some.nested.field'), it will not reset.

The reason because it doesn't acknowledge the nested field name as a field path, and instead treats it as the literal key in the form values. See this line in FormApi.ts.

Your minimal, reproducible example

https://stackblitz.com/edit/vitejs-vite-3nazz9pj?file=src%2FApp.tsx

Steps to reproduce

  1. Go to the repro
  2. Change the shallow field and try to reset it. This works.
  3. Change the nested fied and try to reset it. It won't work.

Expected behavior

As a user, I expect the field name to be translated into the nested field value as that's what the typing implies.

How often does this bug happen?

Every time

Screenshots or Videos

Here's the outcome of what's actually happening behind the scenes:

Image

Platform

Any browser

TanStack Form adapter

None

TanStack Form version

v1.10.0

TypeScript version

v5.8.3

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

      0