react-dropzone: onDrop method not being called after selecting a file.
Do you want to request a feature or report a bug?
- I found a bug
- I want to propose a feature
What is the current behavior?
When I click the dropzone, the file dialog opens. I select a file either by double clicking or clicking the upload button on the dialog. The dialog dismisses.
About 80% of the time, nothing happens. The onDrop method is not called. The remaining 20% of the time, it works as normal.
File is a valid filetype/size and I see no errors on my console.
If I drag and drop a file from Finder, it consistently works as expected - I’ve only encountered this when selecting from a dialog.
What is the expected behavior?
handleDrop gets called consistently and I’m able to upload my file.
Please mention other relevant information such as the browser version, Operating System and react-dropzone version.
- My implementation seemingly mirrors the documentation, and I’m using the latest version.
- My browser is Safari 15, public release version, and I’ve reproduced this using both Big Sur and the Monterrey beta.
- I have not encountered this issue with other versions of Safari.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 11
- Comments: 26
Hi! I just ran into the same issue and I think I finally isolated what’s causing it. It is only happening on Safari for me, Chrome and Firefox function as expected. Versions:
react-dropzone:12.0.2Safari:Version 15.3 (16612.4.9.1.7, 16612)macOS Big Sur 11.6The issue seems to be when trying to assign a custom input id for the file input. With this code below, I’m only seeing the
onDropget called around 30% of the time:With this code below, it gets called 100% of the time:
Is there a better way to be able to assign a custom id to the file input? I haven’t seen anything related to this in the docs. Thanks!
Update: Removing the custom id entirely and nesting the
inputin thelabelalso seems to have the same issue somehow:I seem to be having a similar issue with the same file being uploaded twice, for me using Chrome on Ubuntu. This bug only seems to affect the
inputmechanism: if I select the same file, using the file chooser, the second time nothing happens. If I try then to drag that same file in my dropzone, while in that state, it works though.For me, this isn’t working even for the first time. I’m using React 17+
Those consoles never get printed. On click, I do get file uploader but on selection, nothing happens in the console. Same for drag and drop.
I can confirm this bug still exit with
react-dropzone version 14.2.3onFirefox 112.0.2 (64-bit)onMac Ventra 13.4only tested on Mac, the same issue also exit in safari browser tooit only happens when selecting from the file dialog
I also quick tested with Chrome and it seams to work file when selecting from the file dialog
I have fixed the issue in my context by using the first recipe (with the
openhandler) described here: https://github.com/react-dropzone/react-dropzone/tree/master/examples/file-dialogNote that it seems to work even when the
<input {...getInputProps()} />is completely outside of the component with the{...getRootProps()}.Had the same issue as above, picking the same file a second time yielded no change. I switched my wrapper from a
<label />to a<div />and removedonClick: false, then the file was loading in the second time as expected.I needed dropzone inside a modal window and seems modal window introduces some issue here. Got it working with
noDragEventsBubbling: true,as shown below ,I’ve experimented the same issue, but when trying to upload twice in a row the same file.
I upload it a first time, it works, the
onDropcallback is called. If i upload the same file a second time, it’s not triggered, but if it’s a different file, it will work