Skip to content
Source
Sign inSign up
TanStack/form

fix(form-core): fix fields being stale on array changes #1729

MergedLeCarbonator(GitHub profile, opens in a new tab)merged 22 commits intomain fromrefs/pull/1729/headmerged by LeCarbonator(GitHub profile, opens in a new tab)

Closes #1614 Closes #1561 Closes #1577 Closes #1289

Fixes:

  • field.handleChange(undefined) no longer sets the value to the default value
  • form.reset() and array methods no longer break controlled input when non-index keys are used
  • field values in arrays no longer temporarily become undefined (breaking controlled -> uncontrolled -> controlled)

Todos:

  • Test at workplace (known location where previous implementation crashed due to dnd)
  • Test performance (what does the rerendering look like now?)
    • children callback
    • Form Composition
  • Check other frameworks
    • Solid
    • Angular
    • Vue
    • Svelte
    • Lit
    1. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 4a489fa9a88463737e9c5436692d3b9291a0348c

      CommandStatusDurationResult
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded1m 13sView ↗
      nx run-many --target=build --exclude=examples/**✅ Succeeded32sView ↗

      ☁️ Nx Cloud last updated this comment at 2025-11-24 10:11:17 UTC

    2. pkg-pr-new[bot](GitHub profile, opens in a new tab)commented
      More templates

      @tanstack/angular-form

      npm i https://pkg.pr.new/@tanstack/angular-form@1729

      @tanstack/form-core

      npm i https://pkg.pr.new/@tanstack/form-core@1729

      @tanstack/form-devtools

      npm i https://pkg.pr.new/@tanstack/form-devtools@1729

      @tanstack/lit-form

      npm i https://pkg.pr.new/@tanstack/lit-form@1729

      @tanstack/react-form

      npm i https://pkg.pr.new/@tanstack/react-form@1729

      @tanstack/react-form-devtools

      npm i https://pkg.pr.new/@tanstack/react-form-devtools@1729

      @tanstack/react-form-nextjs

      npm i https://pkg.pr.new/@tanstack/react-form-nextjs@1729

      @tanstack/react-form-remix

      npm i https://pkg.pr.new/@tanstack/react-form-remix@1729

      @tanstack/react-form-start

      npm i https://pkg.pr.new/@tanstack/react-form-start@1729

      @tanstack/solid-form

      npm i https://pkg.pr.new/@tanstack/solid-form@1729

      @tanstack/solid-form-devtools

      npm i https://pkg.pr.new/@tanstack/solid-form-devtools@1729

      @tanstack/svelte-form

      npm i https://pkg.pr.new/@tanstack/svelte-form@1729

      @tanstack/vue-form

      npm i https://pkg.pr.new/@tanstack/vue-form@1729

      commit: 4a489fa

    3. codecov[bot](GitHub profile, opens in a new tab)commented

      Codecov Report

      :x: Patch coverage is 97.70115% with 2 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 90.23%. Comparing base (6892ed0) to head (4a489fa). :warning: Report is 59 commits behind head on main.

      Files with missing linesPatch %Lines
      packages/form-core/src/FieldApi.ts94.73%1 Missing :warning:
      packages/form-core/src/metaHelper.ts98.21%1 Missing :warning:
      Additional details and impacted files
      @@            Coverage Diff             @@
      ##             main    #1729      +/-   ##
      ==========================================
      - Coverage   90.35%   90.23%   -0.13%     
      ==========================================
        Files          38       41       +3     
        Lines        1752     1853     +101     
        Branches      444      469      +25     
      ==========================================
      + Hits         1583     1672      +89     
      - Misses        149      162      +13     
      + Partials       20       19       -1     

      :umbrella: View full report in Codecov by Sentry. :loudspeaker: Have feedback on the report? Share it here.

      :rocket: New features to boost your workflow:

      • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
      • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
  • Notes to self:

    Swapping, deletion and basic reset seems to work. However, there's conflicts with the reset that need further investigating.

  • changeset-bot[bot](GitHub profile, opens in a new tab)commented

    ⚠️ No Changeset found

    Latest commit: 4a489fa9a88463737e9c5436692d3b9291a0348c

    Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

    This PR includes no changesets

    When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

    Click here to learn what changesets are, and how to add one.

    Click here if you're a maintainer who wants to add a changeset to this PR

  • form.reset() still has the issue if the array field's size changes.

    swapValues, moveValues and removeValue seem to be fixed.

  • LeCarbonator(GitHub profile, opens in a new tab)commented

    form.reset() and array methods are all fixed.

    Todos:

    • Test at workplace (known location where previous implementation crashed due to dnd)
    • Test performance (what does the rerendering look like now?)
      • children callback
      • Form Composition
    • Check other frameworks
      • Solid
      • Angular
      • Vue
      • Svelte
      • Lit
  • Solid appears to be struggling with this implementation still. I'll look into what can be done to fix it.

  • LeCarbonator(GitHub profile, opens in a new tab)commented

    Looks like svelte has a problem when using a keyed list

  • Arrays look to be fixed, at least confirmed for React.

    However, it looks like defaultValue and defaultMeta have been broken in the process. This might also highlight stale unit tests, so I'll have to go through that thoroughly.

  • pr works in local code base, and fixes array bug.

  • I'll add a solidjs test later. After that, it's good to merge.

  • Sign in to join this conversation.