diff --git a/packages/core/src/__tests__/form.spec.ts b/packages/core/src/__tests__/form.spec.ts index ad28a904b7a..7d45a056232 100644 --- a/packages/core/src/__tests__/form.spec.ts +++ b/packages/core/src/__tests__/form.spec.ts @@ -144,6 +144,25 @@ test('setValues/setInitialValues', () => { }) }) +test('no field initialValues merge', () => { + const form = attach( + createForm({ + values: { + aa: '123', + }, + initialValues: { + aa: '333', + bb: '321', + }, + }) + ) + + expect(form.values).toEqual({ + aa: '123', + bb: '321', + }) +}) + test('setLoading', async () => { const form = attach(createForm()) expect(form.loading).toBeFalsy() diff --git a/packages/core/src/shared/internals.ts b/packages/core/src/shared/internals.ts index 26685b82bfe..2d08df7132c 100644 --- a/packages/core/src/shared/internals.ts +++ b/packages/core/src/shared/internals.ts @@ -172,7 +172,7 @@ export const patchFormValues = ( if (!isVoidField(targetField) && !targetField.modified) { update(path, source) } - } else { + } else if (form.initialized) { update(path, source) } }