fix: remove active field should not clear value (#4012)

* fix: remove active field

* fix: fix field value submission on field removal

---------

Co-authored-by: Zeke Zhang <958414905@qq.com>
This commit is contained in:
katherinehhh 2024-04-11 17:23:31 +08:00 committed by GitHub
parent fd2becd650
commit 6d7ecba59e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 7 deletions

View File

@ -750,9 +750,9 @@ export const useCurrentSchema = (action: string, key: string, find = findSchema,
exists: !!schema,
remove() {
removeActiveFieldName?.(schema.name);
form?.query(schema.name).forEach((field: Field) => {
field.setInitialValue?.(null);
field.reset?.();
form?.query(new RegExp(`${schema.parent.name}.${schema.name}$`)).forEach((field: Field) => {
// 如果字段被删掉,那么在提交的时候不应该提交这个字段
field.setValue?.(undefined);
});
schema && rm(schema, remove);
},

View File

@ -581,10 +581,10 @@ export const SchemaSettingsRemove: FC<SchemaSettingsRemoveProps> = (props) => {
await confirm?.onOk?.();
delete form.values[fieldSchema.name];
removeActiveFieldName?.(fieldSchema.name as string);
if (field?.setInitialValue && field?.reset) {
field.setInitialValue(null);
field.reset();
}
form?.query(new RegExp(`${fieldSchema.parent.name}.${fieldSchema.name}$`)).forEach((field: Field) => {
// 如果字段被删掉,那么在提交的时候不应该提交这个字段
field.setValue?.(undefined);
});
removeDataBlock(fieldSchema['x-uid']);
},
});