Skip to content

Commit

Permalink
fix(core): fix initial value is filtered when the field is hidden (#3471
Browse files Browse the repository at this point in the history
)
  • Loading branch information
janryWang committed Oct 19, 2022
1 parent e6a61a2 commit 47ee478
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/core/src/__tests__/field.spec.ts
Expand Up @@ -2295,3 +2295,15 @@ test('field actions', () => {
})
expect(aa.invoke('test')).toEqual(321)
})

test('field hidden value', () => {
const form = attach(createForm())
attach(
form.createField({
name: 'aa',
hidden: true,
initialValue: '123',
})
)
expect(form.values).toEqual({ aa: '123' })
})
2 changes: 1 addition & 1 deletion packages/core/src/models/Field.ts
Expand Up @@ -228,7 +228,7 @@ export class Field<
if (this.selfModified && !this.caches.inputting) {
validateSelf(this)
}
if (!this.visible) {
if (this.display === 'none') {
this.caches.value = toJS(value)
this.form.deleteValuesIn(this.path)
}
Expand Down

0 comments on commit 47ee478

Please sign in to comment.