Skip to content

Commit ff1d403

Browse files
authored
feat(core): lock setValue/setInitialValue behavior to untrack (#3331)
1 parent 36f6e03 commit ff1d403

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

.github/workflows/check-pr-title.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
lint:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: aslafy-z/conventional-pr-title-action@master
14+
- uses: aslafy-z/conventional-pr-title-action@v2.4.0
1515
with:
1616
preset: conventional-changelog-angular@^5.0.6
1717
env:

packages/core/src/models/Field.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -348,31 +348,11 @@ export class Field<
348348
}
349349

350350
set value(value: ValueType) {
351-
if (this.destroyed) return
352-
if (!this.initialized) {
353-
if (this.display === 'none') {
354-
this.caches.value = value
355-
return
356-
}
357-
value = getValidFieldDefaultValue(value, this.initialValue)
358-
if (!allowAssignDefaultValue(this.value, value) && !this.designable) {
359-
return
360-
}
361-
}
362-
this.form.setValuesIn(this.path, value)
351+
this.setValue(value)
363352
}
364353

365354
set initialValue(initialValue: ValueType) {
366-
if (this.destroyed) return
367-
if (!this.initialized) {
368-
if (
369-
!allowAssignDefaultValue(this.initialValue, initialValue) &&
370-
!this.designable
371-
) {
372-
return
373-
}
374-
}
375-
this.form.setInitialValuesIn(this.path, initialValue)
355+
this.setInitialValue(initialValue)
376356
}
377357

378358
set selfErrors(messages: FeedbackMessage) {
@@ -432,11 +412,31 @@ export class Field<
432412
}
433413

434414
setValue = (value?: ValueType) => {
435-
this.value = value
415+
if (this.destroyed) return
416+
if (!this.initialized) {
417+
if (this.display === 'none') {
418+
this.caches.value = value
419+
return
420+
}
421+
value = getValidFieldDefaultValue(value, this.initialValue)
422+
if (!allowAssignDefaultValue(this.value, value) && !this.designable) {
423+
return
424+
}
425+
}
426+
this.form.setValuesIn(this.path, value)
436427
}
437428

438429
setInitialValue = (initialValue?: ValueType) => {
439-
this.initialValue = initialValue
430+
if (this.destroyed) return
431+
if (!this.initialized) {
432+
if (
433+
!allowAssignDefaultValue(this.initialValue, initialValue) &&
434+
!this.designable
435+
) {
436+
return
437+
}
438+
}
439+
this.form.setInitialValuesIn(this.path, initialValue)
440440
}
441441

442442
setLoading = (loading?: boolean) => {

0 commit comments

Comments
 (0)