From cd47539e18079dae2871819199d3cd89838c0755 Mon Sep 17 00:00:00 2001 From: Parth <108089718+parthy007@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:04:10 +0530 Subject: [PATCH] Fix: Drag & drop functionality in TJDB dropzone while bulkuploading (#9827) * Allow drag & drop of files in dropzone * Remove unrequired props and correct the condition * fix : extra bullet point of file name is showing in bulk upload ui while drag and drop --------- Co-authored-by: Abd-Rahman-1999 --- .../Drawers/BulkUploadDrawer/FileDropzone.jsx | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/frontend/src/TooljetDatabase/Drawers/BulkUploadDrawer/FileDropzone.jsx b/frontend/src/TooljetDatabase/Drawers/BulkUploadDrawer/FileDropzone.jsx index bdc79f1d98..fa214e0f24 100644 --- a/frontend/src/TooljetDatabase/Drawers/BulkUploadDrawer/FileDropzone.jsx +++ b/frontend/src/TooljetDatabase/Drawers/BulkUploadDrawer/FileDropzone.jsx @@ -12,7 +12,6 @@ export function FileDropzone({ errors, handleFileChange, onButtonClick, - onDrop, setProgress, progress, }) { @@ -23,7 +22,13 @@ export function FileDropzone({ const { getRootProps, getInputProps, isDragActive, acceptedFiles } = useDropzone({ accept: { parsedFileType: ['text/csv'] }, - onDrop, + onDrop: (acceptedFiles) => { + if (acceptedFiles.length === 1) { + const file = acceptedFiles[0]; + setFileData(file); // Set the file data + handleFileChange(file); + } + }, noClick: true, onDropRejected: (files) => { if (Math.round(files[0].size / 1024) > 2 * 1024) { @@ -65,9 +70,13 @@ export function FileDropzone({ <> {fileData?.name ? (
- + {/* */} -
+
{fileData?.name && (
    {` ${fileData?.name} - ${fileData?.size} bytes`}
)} @@ -142,7 +151,11 @@ export function FileDropzone({ className="form-control" data-cy="input-field-bulk-upload" /> -
    {acceptedFiles}
+
    + {acceptedFiles.map((file) => ( +
  • {file.path}
  • + ))} +
{fileData?.name &&
    {` ${fileData?.name} - ${fileData?.size} bytes`}
}