From 714722bb2d09daffbd5b5969f1a0c70dd7f95caf Mon Sep 17 00:00:00 2001 From: Ricky <5317425+rickythink@users.noreply.github.com> Date: Thu, 28 Mar 2024 12:28:15 +0800 Subject: [PATCH] fix: 'next' button unresponsive when uploading additional documents before previous batch completes (#2991) --- .../components/datasets/create/file-uploader/index.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/web/app/components/datasets/create/file-uploader/index.tsx b/web/app/components/datasets/create/file-uploader/index.tsx index 43cab0e949..9264954d87 100644 --- a/web/app/components/datasets/create/file-uploader/index.tsx +++ b/web/app/components/datasets/create/file-uploader/index.tsx @@ -130,7 +130,6 @@ const FileUploader = ({ } } - const fileListCopy = fileListRef.current return upload({ xhr: new XMLHttpRequest(), data: formData, @@ -142,14 +141,14 @@ const FileUploader = ({ file: res, progress: -1, } - const index = fileListCopy.findIndex(item => item.fileID === fileItem.fileID) - fileListCopy[index] = completeFile - onFileUpdate(completeFile, 100, fileListCopy) + const index = fileListRef.current.findIndex(item => item.fileID === fileItem.fileID) + fileListRef.current[index] = completeFile + onFileUpdate(completeFile, 100, fileListRef.current) return Promise.resolve({ ...completeFile }) }) .catch((e) => { notify({ type: 'error', message: e?.response?.code === 'forbidden' ? e?.response?.message : t('datasetCreation.stepOne.uploader.failed') }) - onFileUpdate(fileItem, -2, fileListCopy) + onFileUpdate(fileItem, -2, fileListRef.current) return Promise.resolve({ ...fileItem }) }) .finally()