fix(form-core): bump _arrayVersion when async defaultValues update array fields#2190
fix(form-core): bump _arrayVersion when async defaultValues update array fields#2190mixelburg wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughFormApi.update now detects when array field values change and bumps their metadata versioning to trigger re-renders. A regression test confirms that async-resolved array values in defaultValues properly update form state and UI after initial render. ChangesArray Field Async Value Resolution Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 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 |
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