Skip to content

Commit

Permalink
fix(core): fix initialValues merge with no fields (#2339)
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang authored Oct 22, 2021
1 parent bbb1a5a commit 9c2ebc3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions packages/core/src/__tests__/form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,25 @@ test('setValues/setInitialValues', () => {
})
})

test('no field initialValues merge', () => {
const form = attach(
createForm<any>({
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()
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/shared/internals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export const patchFormValues = (
if (!isVoidField(targetField) && !targetField.modified) {
update(path, source)
}
} else {
} else if (form.initialized) {
update(path, source)
}
}
Expand Down

0 comments on commit 9c2ebc3

Please sign in to comment.