Skip to content

fix(core): recompute field-array dirty state#287

Merged
RtlZeroMemory merged 1 commit intomainfrom
codex/fix-form-array-dirty-errors
Mar 18, 2026
Merged

fix(core): recompute field-array dirty state#287
RtlZeroMemory merged 1 commit intomainfrom
codex/fix-form-array-dirty-errors

Conversation

@RtlZeroMemory
Copy link
Copy Markdown
Owner

@RtlZeroMemory RtlZeroMemory commented Mar 17, 2026

Summary

  • recompute field-array dirty state from the next array snapshot after append/remove/move
  • preserve scalar array-level errors when structural edits happen with validateOnChange: false
  • tighten field-array regressions around length-mismatch dirty semantics and scalar error preservation

Testing

  • npm run build
  • npm run lint
  • npm run typecheck
  • node scripts/run-tests.mjs --filter "form.fieldArray"
  • node scripts/run-tests.mjs --filter "useForm"

Summary by CodeRabbit

Bug Fixes

  • Fixed dirty state tracking for field arrays to accurately reflect changes after append, remove, or move operations.
  • Fixed preservation of array-level errors when validation on change is disabled.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8276eb8c-b9bf-4930-a7f3-4f172212d9ee

📥 Commits

Reviewing files that changed from the base of the PR and between 2980659 and 15a0d1f.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • packages/core/src/forms/__tests__/form.fieldArray.test.ts
  • packages/core/src/forms/internal/arrayState.ts

📝 Walkthrough

Walkthrough

This PR fixes the dirty state recomputation for field arrays after append, remove, and move operations, and ensures array-level scalar errors are preserved when validateOnChange is disabled. Changes include a new error remapping helper, refactored dirty-state logic using computeFieldDirty, and comprehensive regression tests.

Changes

Cohort / File(s) Summary
Documentation
CHANGELOG.md
Added entries documenting bug fixes for useFieldArray dirty state recomputation and error preservation, plus regression test additions.
Tests
packages/core/src/forms/__tests__/form.fieldArray.test.ts
Updated test expectations from per-item dirty arrays to scalar boolean values; added regression tests for array-level error preservation across append/remove/move operations when validateOnChange is disabled.
Core Logic
packages/core/src/forms/internal/arrayState.ts
Introduced remapFieldArrayErrors helper for consistent error array mapping; replaced manual dirty-tracking with computeFieldDirty-based updates; refactored error preservation logic in append, remove, and move operations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Dirty states now recompute clean,
Arrays remember errors unseen,
Append and remove with grace,
Scalar errors find their place,
Field arrays hop along serene!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and concisely describes the main change: recomputing field-array dirty state, which aligns with the PR's primary objective and the modifications across the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-form-array-dirty-errors
📝 Coding Plan
  • Generate coding plan for human review comments

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

@RtlZeroMemory RtlZeroMemory merged commit 4a51e35 into main Mar 18, 2026
32 checks passed
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