onDrop not working
See original GitHub issueDo 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? I’m using the example code from the documentation but the onDrop function is never called. The isDragActive, isDragAccept and isDragReject work fine. Using the file selector works too.
Code:
<Dropzone onDrop={() => alert("Dropped")}>
{({ getRootProps, getInputProps, isDragActive }) => {
return (
<div {...getRootProps()} className={"dropzone" + isDragActive ? " dropzone--isActive" : ""}>
<input {...getInputProps()} />
{isDragActive ? (
<p>Drop files here...</p>
) : (
<p>Try dropping some files here, or click to select files to upload.</p>
)}
</div>
);
}}
</Dropzone>
If the current behavior is a bug, please provide the steps to reproduce.
- Install react-dropzone
- Include code from above
- Drag file(s) from finder onto the dropzone
- Drop file
- Nothing happens, no console output
What is the expected behavior?
- …
- Drop file
- Alert is shown
Please mention other relevant information such as the browser version, Operating System and react-dropzone version.
- macOS High Sierra 10.13.4, Windows 10
- Safari 11.1, Chrome 72.0.3626.109, and Firefox 65.0
- react-dropzone 9.0.0
Issue Analytics
- State:
- Created 5 years ago
- Comments:10
Top Results From Across the Web
Why is ondrop not working? - Stack Overflow
I am trying to get drag and drop working, but I am wiring a function to the 'ondrop' event, but the function is...
Read more >ondrop Event - W3Schools
The ondrop event occurs when a draggable element or text selection is dropped on a valid drop target. Drag and drop is a...
Read more >OnDrop event not firing when dropping ever children elements
OnDrop event not firing when dropping ever children elements. The thing is I made a component for dropping files on it.
Read more >onDrop method not being called after selecting a file. #1097
The onDrop method is not called. The remaining 20% of the time, it works as normal. File is a valid filetype/size and I...
Read more >JavaScript: Solution: drop event not firing - YouTube
A lot of developers bump into this situation. Your dragstart event handler fires but not the handler for the drop event.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Wrapping the Dropzone in a ConnectDropTarget which accepts NativeTypes.FILE works also.
Have same issue, with the same version of react-dropzone and Windows 10 (Google Chrome 72.0.3626.119 ).
Open method works correctly - onDrop don’t launch when You drop file.