Skip to content

Commit

Permalink
fix(@uform/core): fix init visible can not remove value (#492)
Browse files Browse the repository at this point in the history
* refactor(@uform/core): update onFormSubmit position

* fix(@uform/antd/next): fix submit cannot autosubmit

* fix(@uform/core): fix init visible can not remove value
  • Loading branch information
janryWang authored Dec 10, 2019
1 parent 6868656 commit a6dcc18
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function createForm<FieldProps, VirtualFieldProps>(
const mountedChanged = field.isDirty('mounted')
const initializedChanged = field.isDirty('initialized')
const warningsChanged = field.isDirty('warnings')
const errorsChanges = field.isDirty('errors')
const errorsChanged = field.isDirty('errors')
const userUpdateFieldPath =
env.userUpdateFields[env.userUpdateFields.length - 1]
if (initializedChanged) {
Expand All @@ -194,6 +194,16 @@ export function createForm<FieldProps, VirtualFieldProps>(
}, true)
}
}
if (valueChanged) {
userUpdating(field, () => {
setFormValuesIn(path, published.value)
})
heart.publish(LifeCycleTypes.ON_FIELD_VALUE_CHANGE, field)
}
if (initialValueChanged) {
setFormInitialValuesIn(path, published.initialValue)
heart.publish(LifeCycleTypes.ON_FIELD_INITIAL_VALUE_CHANGE, field)
}
if (displayChanged || visibleChanged) {
if (visibleChanged) {
if (!published.visible) {
Expand Down Expand Up @@ -228,18 +238,8 @@ export function createForm<FieldProps, VirtualFieldProps>(
if (mountedChanged && published.mounted) {
heart.publish(LifeCycleTypes.ON_FIELD_MOUNT, field)
}
if (valueChanged) {
userUpdating(field, () => {
setFormValuesIn(path, published.value)
})
heart.publish(LifeCycleTypes.ON_FIELD_VALUE_CHANGE, field)
}
if (initialValueChanged) {
setFormInitialValuesIn(path, published.initialValue)
heart.publish(LifeCycleTypes.ON_FIELD_INITIAL_VALUE_CHANGE, field)
}

if (errorsChanges) {
if (errorsChanged) {
syncFormMessages('errors', published.name, published.errors)
}

Expand Down Expand Up @@ -703,7 +703,10 @@ export function createForm<FieldProps, VirtualFieldProps>(
return arr
},
validate(opts?: IFormExtendedValidateFieldOptions) {
return validate(field.getSourceState(state => state.path), opts)
return validate(
field.getSourceState(state => state.path),
opts
)
}
}
}
Expand Down

0 comments on commit a6dcc18

Please sign in to comment.