Skip to content

Commit

Permalink
fix(@uform/core): Fix value synchronization of field state
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Jun 25, 2019
1 parent 4dc4d86 commit 38dc0aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/core/src/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ export class Field {
}

publishState() {
return publishFieldState(this)
}

syncContextValue() {
if (this.visible) {
const contextValue = this.context.getValue(this.name, true)
const contextInitialValue = this.context.getInitialValue(
Expand All @@ -168,7 +172,6 @@ export class Field {
this.initialValue = contextInitialValue
}
}
return publishFieldState(this)
}

subscribe(callback) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export class Form {
}
})
if (field) {
field.syncContextValue()
return isFn(callback)
? callback(field.publishState())
: field.publishState()
Expand Down

0 comments on commit 38dc0aa

Please sign in to comment.