question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onDrop not working

See original GitHub issue

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? 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.

  1. Install react-dropzone
  2. Include code from above
  3. Drag file(s) from finder onto the dropzone
  4. Drop file
  5. Nothing happens, no console output

What is the expected behavior?

  1. Drop file
  2. 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:closed
  • Created 5 years ago
  • Comments:10

github_iconTop GitHub Comments

2reactions
mzl-kicommented, Mar 6, 2019

Wrapping the Dropzone in a ConnectDropTarget which accepts NativeTypes.FILE works also.

2reactions
darekchynekcommented, Feb 26, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found