diff --git a/packages/core/src/__tests__/array.spec.ts b/packages/core/src/__tests__/array.spec.ts index 4eab9fc15be..82a31113825 100644 --- a/packages/core/src/__tests__/array.spec.ts +++ b/packages/core/src/__tests__/array.spec.ts @@ -571,3 +571,52 @@ test('incomplete insertion of array elements', async () => { expect(form.fields['array.2.aa']).toBeUndefined() expect(form.fields['array.3.aa']).not.toBeUndefined() }) + +test('void array items need skip data', () => { + const form = attach(createForm()) + const array = attach( + form.createArrayField({ + name: 'array', + }) + ) + const array2 = attach( + form.createArrayField({ + name: 'array2', + }) + ) + attach( + form.createVoidField({ + name: '0', + basePath: 'array', + }) + ) + attach( + form.createVoidField({ + name: '0', + basePath: 'array2', + }) + ) + attach( + form.createVoidField({ + name: 'space', + basePath: 'array.0', + }) + ) + const select = attach( + form.createField({ + name: 'select', + basePath: 'array.0.space', + }) + ) + const select2 = attach( + form.createField({ + name: 'select2', + basePath: 'array2.0', + }) + ) + + select.value = 123 + select2.value = 123 + expect(array.value).toEqual([123]) + expect(array2.value).toEqual([123]) +}) diff --git a/packages/core/src/shared/internals.ts b/packages/core/src/shared/internals.ts index 6347ff35345..411f0608d9b 100644 --- a/packages/core/src/shared/internals.ts +++ b/packages/core/src/shared/internals.ts @@ -114,7 +114,9 @@ export const buildFieldPath = (field: GeneralField) => { const currentAddress = segments.slice(0, index + 1) const current = fields[currentAddress.join('.')] if (prevArray) { - prevArray = false + if (!isVoidField(current)) { + prevArray = false + } return path } if (index >= segments.length - 1) {