Skip to content

Commit e226ffe

Browse files
committed
chore: update values
1 parent 9a49d45 commit e226ffe

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
},
5151
"dependencies": {
5252
"@rc-component/async-validator": "^5.0.3",
53-
"@rc-component/util": "^1.3.0",
53+
"@rc-component/util": "^1.5.0",
5454
"clsx": "^2.1.1"
5555
},
5656
"devDependencies": {

src/useForm.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { merge } from '@rc-component/util/lib/utils/set';
2+
import { mergeWith } from '@rc-component/util';
23
import warning from '@rc-component/util/lib/warning';
34
import * as React from 'react';
45
import { HOOK_MARK } from './FieldContext';
@@ -786,7 +787,10 @@ export class FormStore {
786787
const changedValues = cloneByNamePathList(this.store, [namePath]);
787788
const allValues = this.getFieldsValue();
788789
// Merge changedValues into allValues to ensure allValues contains the latest changes
789-
const mergedAllValues = merge(allValues, changedValues);
790+
const mergedAllValues = mergeWith([allValues, changedValues], {
791+
// When value is array, it means trigger by Form.List which should replace directly
792+
prepareArray: current => (Array.isArray(value) ? [] : [...(current || [])]),
793+
});
790794
onValuesChange(changedValues, mergedAllValues);
791795
}
792796

0 commit comments

Comments
 (0)