Skip to content

Commit 4e69d82

Browse files
committed
feat: review
1 parent 3282cba commit 4e69d82

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/useForm.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -910,8 +910,7 @@ export class FormStore {
910910
const namePathList: InternalNamePath[] | undefined = provideNameList
911911
? nameList.map(getNamePath)
912912
: [];
913-
914-
const removeListNameStrList: string[] = [];
913+
const noListNamePathList = [...namePathList];
915914

916915
// Collect result in promise list
917916
const promiseList: Promise<FieldError>[] = [];
@@ -927,8 +926,11 @@ export class FormStore {
927926

928927
// Add field if not provide `nameList`
929928
if (!provideNameList) {
930-
if (field.isList() && namePathList.some(name => matchNamePath(name, fieldNamePath, true))) {
931-
removeListNameStrList.push(fieldNamePath.toString());
929+
if (
930+
// When Form.List has a value, filter Form.List `name`
931+
!(field.isList() && namePathList.some(name => matchNamePath(name, fieldNamePath, true)))
932+
) {
933+
noListNamePathList.push(fieldNamePath);
932934
}
933935
namePathList.push(fieldNamePath);
934936
}
@@ -1006,10 +1008,7 @@ export class FormStore {
10061008
const returnPromise: Promise<Store | ValidateErrorEntity | string[]> = summaryPromise
10071009
.then((): Promise<Store | string[]> => {
10081010
if (this.lastValidatePromise === summaryPromise) {
1009-
const filterListNameList = namePathList.filter(
1010-
name => !removeListNameStrList.some(nameStr => nameStr === name.toString()),
1011-
);
1012-
return Promise.resolve(this.getFieldsValue(filterListNameList));
1011+
return Promise.resolve(this.getFieldsValue(noListNamePathList));
10131012
}
10141013
return Promise.reject<string[]>([]);
10151014
})

0 commit comments

Comments
 (0)