Skip to content

[v2] Fix: Keep ArrayField in sync after array replacement - #2356

Open
scttcper wants to merge 1 commit into
TanStack:alphafrom
scttcper:scttcper/arrayfield-sync
Open

[v2] Fix: Keep ArrayField in sync after array replacement#2356
scttcper wants to merge 1 commit into
TanStack:alphafrom
scttcper:scttcper/arrayfield-sync

Conversation

@scttcper

Copy link
Copy Markdown

ArrayField only reacts to array length and _arrayVersion, so replacing an array with a different array of the same length updated form state without rerendering the array container. UI rendered from the array could stay stale while submission used the new values.

This bumps _arrayVersion for direct same-length replacements. Array helpers now rely on length changes or this shared behavior instead of manually updating the version, while nested field updates still avoid rerendering the parent ArrayField.

Replacing an array with another array of the same length updated form state without rerendering ArrayField.

Bump the shared array version for direct replacements while keeping nested field updates isolated.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

鉂わ笍 Share

Comment @coderabbitai help to get the list of available commands.

expect(input).toHaveValue('new-value')
})

it('rerenders an ArrayField for a same-length replacement', () => {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test does fail without the change

@scttcper
scttcper marked this pull request as ready for review August 24, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant