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.

Regression: Unable to click DOM elements inside drop zone with recommended code

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?

The removal of disableClick in https://github.com/react-dropzone/react-dropzone/pull/767 has caused a regression. You are now unable to click on buttons inside a dropzone when performing the recommended alternative because propagation is stopped entirely:

{onClick: evt => evt.preventDefault()} // stops all propagtion

disableClick skipped the dropzone element, but continued propagation.

The following replacement stops all propagation and is functionally different:

return (
      <Dropzone
        accept={accept}
        onDrop={this.onDrop.bind(this)}
      >
        {({getRootProps, getInputProps, isDragActive}) => (
            <div {...getRootProps({onClick: evt => evt.preventDefault()})} style={{position: "relative"}}>
              <input {...getInputProps()} />

https://github.com/react-dropzone/react-dropzone/pull/767/files#diff-0b1f9c3babb635d33ee2724a6f8d78b9

If the current behavior is a bug, please provide the steps to reproduce.

The Fullscreen example that would reproduce this has been removed in commit https://github.com/react-dropzone/react-dropzone/commit/5398f44f8fdcab8429b0c7769161bba72dad2800#diff-0b1f9c3babb635d33ee2724a6f8d78b9. (Why?)

  1. Create a button inside the fullscreen dropzone
  2. Disable click on dropzone by following the recommendation
  3. Unable to click button.

Or just add a button inside https://github.com/rolandjitsu/react-dropzone/blob/c31e06e93a96162e4c23cd1167270ac61a1bddf5/examples/Fullscreen/Readme.md

What is the expected behavior?

I am able to click the button inside the dropzone.

Please mention other relevant information such as the browser version, Operating System and react-dropzone version.

  1. Broken in v9 and v10, as a result of https://github.com/react-dropzone/react-dropzone/pull/767.
  2. This can be seen because the old logic would continue propagating the click without invoking the file dialog:
if (!disableClick && !isDefaultPrevented(evt)) { // I can disable click but still continue propagation
      evt.stopPropagation()
  1. Would love to see the return of a full screen dropzone example.
  2. Let’s bring back disableClick, it is functionally different to the current approach.

Thanks for all the cleanup and work!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:9

github_iconTop GitHub Comments

1reaction
damianobarbaticommented, Mar 15, 2021

@localjo honestly I’m not understanding. Does the following work for you?

<div {...getRootProps({ onClick: e => e.stopPropagation() })}>
            <input {...getInputProps()} />

Because it totally stops the dialog from opening to me.

1reaction
localjocommented, Mar 13, 2019

Hmm… now it’s working. I must have had my wires crossed somewhere. I’ve been struggling with this all morning. Sorry for the confusion.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dropzone does not click and does not work
The first thing you need to do is to open devtools in the browser and check for errors you need to debug. –...
Read more >
16 Selenium Best Practices For Efficient Test Automation
Discover the top 16 Selenium automation best practices that will help you become a top notch automated testing specialist. Learn more.
Read more >
HP LoadRunner v11 00 - Ajax TruClient Tips and Tricks
Documentation, and Technical Data for Commercial Items are licensed to the ... How to Select an Object in the Application when Mouse and...
Read more >
Cisco Finesse Desktop Interface
This guide discusses the Finesse desktop as it appears out of the box. Note. Finesse Agent Desktop. After you sign in, you can...
Read more >
Diabetes
Pump therapy is not recommended for people who are unwilling or unable to maintain ... Insulin infusion pumps and associated components of insulin...
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