Skip to content

Commit

Permalink
feat(core): lock setValue/setInitialValue behavior to untrack (#3331)
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Aug 11, 2022
1 parent 36f6e03 commit ff1d403
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: aslafy-z/conventional-pr-title-action@master
- uses: aslafy-z/conventional-pr-title-action@v2.4.0
with:
preset: conventional-changelog-angular@^5.0.6
env:
Expand Down
48 changes: 24 additions & 24 deletions packages/core/src/models/Field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,31 +348,11 @@ export class Field<
}

set value(value: ValueType) {
if (this.destroyed) return
if (!this.initialized) {
if (this.display === 'none') {
this.caches.value = value
return
}
value = getValidFieldDefaultValue(value, this.initialValue)
if (!allowAssignDefaultValue(this.value, value) && !this.designable) {
return
}
}
this.form.setValuesIn(this.path, value)
this.setValue(value)
}

set initialValue(initialValue: ValueType) {
if (this.destroyed) return
if (!this.initialized) {
if (
!allowAssignDefaultValue(this.initialValue, initialValue) &&
!this.designable
) {
return
}
}
this.form.setInitialValuesIn(this.path, initialValue)
this.setInitialValue(initialValue)
}

set selfErrors(messages: FeedbackMessage) {
Expand Down Expand Up @@ -432,11 +412,31 @@ export class Field<
}

setValue = (value?: ValueType) => {
this.value = value
if (this.destroyed) return
if (!this.initialized) {
if (this.display === 'none') {
this.caches.value = value
return
}
value = getValidFieldDefaultValue(value, this.initialValue)
if (!allowAssignDefaultValue(this.value, value) && !this.designable) {
return
}
}
this.form.setValuesIn(this.path, value)
}

setInitialValue = (initialValue?: ValueType) => {
this.initialValue = initialValue
if (this.destroyed) return
if (!this.initialized) {
if (
!allowAssignDefaultValue(this.initialValue, initialValue) &&
!this.designable
) {
return
}
}
this.form.setInitialValuesIn(this.path, initialValue)
}

setLoading = (loading?: boolean) => {
Expand Down

0 comments on commit ff1d403

Please sign in to comment.