fix(vue-form): keep field slot state reactive#2192
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 (3)
📝 WalkthroughWalkthroughFixes the regression in version 1.32.0 where Field scoped slot state became stale after field updates. useField now returns state as a getter that dynamically reads fieldState.value, ensuring slot consumers see reactive updates. Includes comprehensive test coverage validating state reactivity after changes, resets, and meta updates. ChangesField slot state reactivity fix
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 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 |
There was a problem hiding this comment.
Pull request overview
This PR fixes stale Vue Field scoped slot state by returning useField().state through a getter, so render-time reads observe the latest computed field state.
Changes:
- Exposes
useField().stateas a getter instead of a setup-time snapshot. - Adds a regression test covering slot
state.valueandstate.meta.errorMap.onServerupdates. - Adds a patch changeset for
@tanstack/vue-form.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/vue-form/src/useField.tsx |
Updates the returned state property to resolve the latest fieldState.value. |
packages/vue-form/tests/useField.test.tsx |
Adds regression coverage for reactive scoped slot state after typing, reset, and meta updates. |
.changeset/vue-form-field-slot-state.md |
Records a patch release note for the Vue form fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
useField().stateas a getter so Vue renders read the latest computed field statevue-formregression test for theFieldscoped slotstate@tanstack/vue-formRoot cause
useFieldreturnedstate: fieldState.value, which captured the field state object once during setup.field.statestayed reactive through its getter, but thestatevalue passed to theFieldscoped slot could become stale after value or meta updates.Fixes #2191
Checks
pnpm --filter @tanstack/vue-form test:lib -- --runpnpm --filter @tanstack/vue-form test:eslintpnpm --filter @tanstack/vue-form buildI also verified that the new regression test fails on
mainbefore this fix.Summary by CodeRabbit