fix(form-core): bump _arrayVersion when async defaultValues update array fields#2190
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughFormApi.update now detects array-typed field values and bumps their array metadata versions when values update. A regression test confirms async-resolved array defaultValues re-render the array field, and a changeset records a patch bump for ChangesArray Field Async Value Resolution Fix
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
crutchcorn
left a comment
There was a problem hiding this comment.
This fix makes a lot of sense. Thanks for the PR and tests
|
View your CI Pipeline Execution ↗ for commit 7f33ac6
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/react-form/tests/useField.test.tsx`:
- Line 1546: The test fails because the <ol> element uses the wrong attribute
name `data-mtestid="list"`; update that attribute to `data-testid="list"` so the
test's calls to getByTestId('list') can find the element—search for the <ol> in
the useField.test.tsx test and replace `data-mtestid` with `data-testid` where
the list is rendered.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ebbab2ab-e11a-4a15-b313-5202306a23bb
📒 Files selected for processing (1)
packages/react-form/tests/useField.test.tsx
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2190 +/- ##
==========================================
+ Coverage 90.35% 91.42% +1.06%
==========================================
Files 38 59 +21
Lines 1752 2343 +591
Branches 444 585 +141
==========================================
+ Hits 1583 2142 +559
- Misses 149 180 +31
- Partials 20 21 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fixes #2178
When async
defaultValuesresolve and update the form, array fields rendered withmode="array"were not re-rendering. This is a regression from #2172 which changed the array field reactivity signal fromObject.keys(value ?? []).lengthtostate.meta._arrayVersion. The_arrayVersioncounter is bumped on explicit mutations (push/insert/remove/swap/move) but not whendefaultValueschange asynchronously.The fix: after the store update in
FormApi.update(), iterate over registered fields and bump_arrayVersionfor any whose current value is an array. Added a regression test.Summary by CodeRabbit
Bug Fixes
Tests
Chores