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.

onDragLeave won't call back when react-dropzone has input element as children

See original GitHub issue

If i create a dropzone with input element as children, the dragleave callback won’t be call correctly.

  <Dropzone disableClick multiple={false}>
       <div><input type='text' /></div>
  </Dropzone>

Here is the screenshot after drag in and dragout a while, the dragleave won’t callback anymore

input

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

4reactions
NervosaXcommented, Mar 1, 2016

This works around the issue by just not using the dropzone dragLeave, instead using a wrapper div.

@nqbao This might help you.

<div onDragLeave={this.handleDragLeave.bind(this)}>
    <Dropzone
        className={classes}
        style={{}}
        onDrop={this.handleDrop.bind(this)}
        onDragEnter={this.handleDragEnter.bind(this)}>

        {this.state.dropEnter ? (
            <div>Drop image here</div>
        ) : (
            <div>
                <Icon value="photo" />
                <div>Click to select an image or drag one here</div>
            </div>
        )}
    </Dropzone>
</div>
0reactions
romkricommented, Jun 21, 2018
DragOver(e){
      if(this.dragTimer) clearTimeout(this.dragTimer);
      var me = this;
      this.dragTimer = setTimeout(function(){
          me.setState({drag:false});
      },100);

     e.preventDefault();
     this.setState({drag:true});
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML5 dragleave fired when hovering a child element
It's necessary to move completely out of the drop div and drag back into it again to make it red. Is it possible...
Read more >
react-dropzone
Simple React hook to create a HTML5-compliant drag'n'drop zone for files. Documentation and examples at https://react-dropzone.js.org.
Read more >
Dropzone - React - Procore
Files are accepted or rejected based on the accept, multiple, minFileSize and maxFileSize props. Accept must be a valid MIME type according to...
Read more >
Drag & Drop - Uppy
The @uppy/drag-drop plugin renders a drag and drop area for file selection. it can be useful when you only want the local device...
Read more >
React Dropzone and File Uploads in React - Upmostly
If you don't have an existing React project that uses the react-dropzone library, generate a new ... Clicking a file to upload won't...
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