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

[BUG] Using onDrop function returns empty acceptedFiles when fileRejections are present #1355

Open
oxuk85 opened this issue Apr 9, 2024 · 0 comments
Labels

Comments

@oxuk85
Copy link

oxuk85 commented Apr 9, 2024

I am using react-dropzone as a way to populate a React-Hook-Form with images.

I am using the onDrop callback which expects a list with acceptedFiles, that I can then use to append the images to the form.

What I have noticed is that when I use the maxFiles flag with a number bigger than the number of images dropped; or multiple flag to false, and I drop more than one image; the onDrop callback does not return any image in the acceptedFiles list.

See codesandbox: https://codesandbox.io/p/sandbox/react-dropzone-on-drop-not-returning-acceptedfiles-lkt5fg?file=%2Fsrc%2FApp.tsx%3A21%2C12
In this sandbox I have used maxFiles but setting multiple to false shows the same result.

As per the documentation:
If multiple is set to false and additional files are dropped, all files besides the first will be rejected. Any file which does not have a size in the [minSize, maxSize] range, will be rejected as well.

I expected the first file to be returned and the rest to be rejected in the case where I set multiple to false, and the files within the maxFiles range to be returned. Right now all files are rejected.

@oxuk85 oxuk85 added the bug label Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant