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

onDrop not working #770

Closed
1 of 2 tasks
mzl-ki opened this issue Feb 26, 2019 · 10 comments
Closed
1 of 2 tasks

onDrop not working #770

mzl-ki opened this issue Feb 26, 2019 · 10 comments

Comments

@mzl-ki
Copy link

mzl-ki commented Feb 26, 2019

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. ...
  2. Drop file
  3. 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
@darekchynek
Copy link

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.

@rolandjitsu
Copy link
Collaborator

Doing this on react-dropzone.js.org works just fine (the basic example shows the file you dropped).

So I'm not sure what you're experiencing. Please provide an example on codesandbox or some other tool.

@alfaslash
Copy link

@ppi-mzl are you used React DnD?

@darekchynek
Copy link

We're using React Dnd with react-sortable-tree.

@alfaslash
Copy link

@darekchynek This problem in React DND react-dnd/react-dnd#457

@mzl-ki
Copy link
Author

mzl-ki commented Feb 27, 2019

@ppi-mzl are you used React DnD?

Yes we are using react-dnd and using the fork / nmp Package of @silvainSayduck instead fixes the issue.

So this is not a bug in react-dropzone but react-dnd. Maybe this should be mentioned in the documentation since this seems to be a common error.

@mzl-ki mzl-ki closed this as completed Feb 27, 2019
@mzl-ki
Copy link
Author

mzl-ki commented Mar 6, 2019

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

@ronaiza-cardoso
Copy link

ronaiza-cardoso commented Jul 1, 2019

I'm using "react-beautiful-dnd": "^10.0.4", and is not working. "react-dropzone": "^7.0.1",. When is on localhost works like expected but when build to prod doesn't work. I'm not using hooks.

@felipe-vicente
Copy link

felipe-vicente commented Oct 16, 2019

In case of anyone having an issue that "looks like this one". Sometimes browsers use diferente MIME_TYPE for diferente file types. I had a problem with 'text/csv' mimetype more info, wich did not work on Chrome running on Windows. Took a while to detect the cause.

I just wanted to write it here so developers with the same problem I had won't lose time thinking it could be any more complex error. Cheers

@isahohieku
Copy link

isahohieku commented Oct 16, 2021

So on my own part, the major issue was this line

<div {...getRootProps({ className: '${styles.dropZone}' })}>

I omitted the className dropzone

On changing to this

<div {...getRootProps({ className: '${styles.dropZone} dropzone' })}>,

It started Working well. Which means the class dropzone must be used and not negotiable.

Pardon my use of single quote where I needed to use a back tick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants