Browse Source

fix: Form ArrayField addWithInitValue should clone params, close #2351 (#2361)

pointhalo 1 year ago
parent
commit
26989f5eff
1 changed files with 2 additions and 1 deletions
  1. 2 1
      packages/semi-ui/form/arrayField.tsx

+ 2 - 1
packages/semi-ui/form/arrayField.tsx

@@ -142,7 +142,8 @@ class ArrayFieldComponent extends Component<ArrayFieldProps, ArrayFieldState> {
         const updater = this.context;
         const { field } = this.props;
         const newArrayFieldVal = updater.getValue(field) ? updater.getValue(field).slice() : [];
-        newArrayFieldVal.push(rowVal);
+        const cloneRowVal = copy(rowVal);
+        newArrayFieldVal.push(cloneRowVal);
         updater.updateStateValue(field, newArrayFieldVal, {});
         updater.updateArrayField(field, { updateKey: new Date().valueOf() });
     }