Skip to content

Commit 66ffeb6

Browse files
authored
fix(core): fix set initialValue no cache value when display none (#3182)
1 parent bf4e035 commit 66ffeb6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/core/src/__tests__/field.spec.ts

+5
Original file line numberDiff line numberDiff line change
@@ -2247,4 +2247,9 @@ test('field destroyed or display none should not be assign value from patch init
22472247
aa.initialValue = '123'
22482248

22492249
expect(form.values).toEqual({})
2250+
2251+
aa.display = 'visible'
2252+
2253+
expect(aa.value).toBe('123')
2254+
expect(form.values).toEqual({ aa: '123' })
22502255
})

packages/core/src/shared/internals.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,10 @@ export const patchFormValues = (
201201
const targetField = form.query(path).take()
202202
const isUnVoidField = targetField && !isVoidField(targetField)
203203

204-
if (isUnVoidField && targetField.display === 'none') return
204+
if (isUnVoidField && targetField.display === 'none') {
205+
targetField.caches.value = clone(source)
206+
return
207+
}
205208

206209
if (allowAssignDefaultValue(targetValue, source)) {
207210
update(path, source)

0 commit comments

Comments
 (0)