From 8df527f7e98f22f6b373a59b894eacc14f399afd Mon Sep 17 00:00:00 2001 From: lyf-coder <58352715+lyf-coder@users.noreply.github.com> Date: Mon, 31 Oct 2022 11:30:56 +0800 Subject: [PATCH] fix(client/upload): fix upload mutiple files always uploading status (#974) --- .../client/src/schema-component/antd/upload/shared.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/upload/shared.ts b/packages/core/client/src/schema-component/antd/upload/shared.ts index 2d166f5116..df77fbd91d 100644 --- a/packages/core/client/src/schema-component/antd/upload/shared.ts +++ b/packages/core/client/src/schema-component/antd/upload/shared.ts @@ -167,12 +167,13 @@ export function useUploadProps({ serviceEr props.onChange?.(normalizeFileList([...param.fileList])); }; - const form = useForm(); - const api = useAPIClient(); return { ...props, + // in customRequest method can't modify form's status(e.g: form.disabled=true ) + // that will be trigger Upload component(actual Underlying is AjaxUploader component )'s componentWillUnmount method + // which will cause multiple files upload fail customRequest({ action, data, file, filename, headers, onError, onProgress, onSuccess, withCredentials }) { const formData = new FormData(); if (data) { @@ -181,7 +182,6 @@ export function useUploadProps({ serviceEr }); } formData.append(filename, file); - form.disabled = true; api.axios .post(action, formData, { withCredentials, @@ -194,9 +194,7 @@ export function useUploadProps({ serviceEr onSuccess(data, file); }) .catch(onError) - .finally(() => { - form.disabled = false; - }); + .finally(() => {}); return { abort() {