Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploaded file deletion event immediately re-triggers file re-upload #18

Closed
IvoLeist opened this issue Dec 11, 2023 · 1 comment · Fixed by #19
Closed

Uploaded file deletion event immediately re-triggers file re-upload #18

IvoLeist opened this issue Dec 11, 2023 · 1 comment · Fixed by #19
Assignees
Labels
bug Something isn't working

Comments

@IvoLeist
Copy link
Member

Details

Introducing a timeout value to fix stalled uploads seem to have broken the uploaded file deletion.
When clicking on delete the file is immediately re-uploaded...
See the gif below.

file-deletion-reupload-loop

Already filed a github issue in the Filepond repository:
pqina/filepond#950

@IvoLeist IvoLeist added the bug Something isn't working label Dec 11, 2023
@IvoLeist IvoLeist self-assigned this Dec 11, 2023
@IvoLeist
Copy link
Member Author

IvoLeist commented Dec 11, 2023

Realized that this issue is react specific, thus opened an issue in here as well:
pqina/react-filepond#239

narrowed the cause for the issue down to setUploadedFiles being called in the onremovefile event handler (see below)

onremovefile={(_, file) => {
   setFilesUploadFinished(false);
   const fileName = file.filename;

   // only update state if the file processing was finished (status 2 = IDLE)
   // for reference see
   // github.com/pqina/filepond-docs/blob/master/content/patterns/API/filepond-object.md#filestatus-enum
   // if below is commented out it is working on the live environment
       if (
             file.status === 2 &&
             file.getMetadata("processingAborted") !== true
       ) {
        setUploadedFiles((prev) => {
          const prevCopy = { ...prev };
          delete prevCopy[fileName];
          return prevCopy;
        });
     }
}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant