Skip to content

Commit

Permalink
fix: form.setValues unexpected reset other fields value
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzishun committed May 30, 2023
1 parent f8fba26 commit cc51a51
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/semi-foundation/form/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,12 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
setValues(values: any, { isOverride = false }): void {
const _values = this._adapter.cloneDeep(values);
this.fields.forEach(field => {
// If field is not in _values, it means that the field should not be updated, so return directly
// 如果field不在_values中,说明该field不应该被更新,所以直接return
if (ObjectUtil.has(_values, field.field)) {
return;
}

const value = ObjectUtil.get(_values, field.field);
// When calling setValues to override the values, only need to trigger onValueChange and onChange once, so setNotNotify of setValue to true
// 调用setValues进行值的覆盖时,只需要回调一次onValueChange、onChange即可,所以此处将setValue的notNotify置为true
Expand Down

0 comments on commit cc51a51

Please sign in to comment.