Skip to content
Source
Sign inSign up
TanStack/form

[v2] Fix(vue): Keep `field.name` reactive after keyed array mutations #2460

Openawdr74100(GitHub profile, opens in a new tab)wants to merge 1 commit intoalpha fromrefs/pull/2460/headopened

Showing 7 changed files with 9 additions and 2 deletions (loading 4).

x
0 of 7 viewed, 7 left
5 additions and 0 deletions.changeset/keyed-array-field-names.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/vue-form': patch
+---
+​
+Keep `field.name` reactive in child and injected field components when an array mutation moves a keyed item's field to a new index.
2 additions and 2 deletionspackages/vue-form/src/VueForm/Components.lib.tsModified
View file
@@ -56,11 +56,11 @@
return defineComponent(
(_props, context) => {
const options = () => ({ ...context.attrs, form }) as never
- const fieldApi = useField(options)
+ const { fieldApi, name } = useField(options)
const { selection, meta } = array
? createArrayFieldSubscription(fieldApi)
: createValueFieldSubscription(fieldApi)
- const field = createFieldView(fieldApi, selection, meta)
+ const field = createFieldView(fieldApi, name, selection, meta)
if (fieldComponents !== null) Object.assign(field, fieldComponents)
​
if (fieldContext) {
2 additions and 0 deletionspackages/vue-form/src/VueForm/fieldView.lib.tsModified
View file
@@ -9,6 +9,7 @@
*/
export function createFieldView(
fieldApi: ShallowRef<AnyInternalFieldApi>,