TanStack / TanStack/form

[v2] Add a listener for array-level field changes

Open
#2,300 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: runtime area: types scope: core type: enhancement v2
Dominant language
TypeScript
Stars
6.7k
Forks
682
Avg merge
5d 18h
Merged PRs (30d)
7

Description

An array field's change listener runs whenever any of its subfields changes. However, consumers may only be interested in changes to the array itself, such as moving an item, rather than changes to the values inside each item.

It would be useful to provide a dedicated listener for these array-level operations. This would let consumers react to changes in the array's structure or ordering without also handling every nested field change.

Some thoughts

One possible implementation is to trigger the listener from changes to _arrayVersion. Whether that internal value should be exposed directly or used behind a higher-level listener API is open for discussion.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing where the internal _arrayVersion value changes and where array-field listeners are registered. Determine how a dedicated listener can distinguish array structure or ordering changes from nested field changes, then verify that structural changes notify it without notifying it for nested value changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.