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.

Suggestion: Option to prevent dragging and dropping elements on the page onto the dropzone

See original GitHub issue

In the meantime, here is my solution for doing this:

onDragEnter={function( event ) {
    const dt = event.dataTransfer;
    if ( !(
        dt.types &&
        ( dt.types.indexOf ? dt.types.indexOf( "Files" ) !== -1 : dt.types.contains( "Files" ) )
    ) ) {
        this.setState( { isDragActive: false } );
    }
}}
onDrop={files => {
    if ( files.length === 0 ) {
        return;
    }

    // handle files dropped here
}}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:9
  • Comments:28 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
rascocommented, Aug 30, 2017

Well one part of the problem is this: The preview creation (window.URL.createObjectURL(file)) is done on all files, regardless whether they are accepted or not. Shouldn’t previews only be created for accepted files?

5reactions
stale[bot]commented, Mar 12, 2018

This issue has been automatically marked as stale because it has not had recent activity in the past 60 days. It will be closed if no further activity occurs. If the problem persists please comment here to bump your issue. Thank You - React Dropzone Maintaners

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prevent browser from loading a drag-and-dropped file
Using the following code (based on @digital-plane's answer) the page becomes a drag target, it prevents object embeds from capturing the events and...
Read more >
HTML Drag and Drop API - W3Schools
In HTML, any element can be dragged and dropped. ... Drag the W3Schools image into the rectangle. Drag and Drop. Drag and drop...
Read more >
Drag'n'Drop with mouse events - The Modern JavaScript Tutorial
Drag'n'Drop is a great interface solution. Taking something and dragging and dropping it is a clear and simple way to do many things, ......
Read more >
Moodle 2.3 :: how to disable the dragging and dropping of files
I have eliminated drag and drop to course page by customizing course/dndupload.js (making function upload_file return false inmediatly), but thsi hack affects ...
Read more >
Confluence disable the drag and drop attachment into a page ...
provide a smaller drop zone instead of the full page; at least disable drops that origin from that very page. To highlight my...
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