Topic: Button Component Registering Double Click onClick

Ben Hagan free asked 5 years ago


When clicking on a Button component with an onClick prop, the function fires twice, once on the downclick, and once on the click release.

Could this be related to https://mdbootstrap.com/support/floating-button-onclick-issue-with-firefox/?

Here's the code:

<Button
color="info"
onClick={() => {
this.props.toggleShowCleared();
}}
>
Show Cleared
</Button>


Jakub Strebeyko staff answered 5 years ago


Hi there Ben, Honestly I don't really know what could go wrong. Please excuse me asking on, but is this behavior taking place regardless of the function being passed (as in this.props passed function or a simple one being defined on the component)? Seeking clues. With Best Regards, Kuba

Ben Hagan free answered 5 years ago


Using latest from npm, 4.6.1.  I started a new create-react-app as recommended and changed the onclick callback in the button to simply run a console.log as recommended, and I still get two calls (logs) for each click in Firefox (61.0.1) and in Chromium (68.0.3440.84).

Jakub Strebeyko staff answered 5 years ago


Hi there Ben, Welcome to the MDB React Support Board! The issue referenced had to do with waves effect and ended up requiring FireFox users to double click on buttons to have their callbacks run as expected. It has resolved in 4.6.1 and now pasting the button code into our App (or a create-react-app-created app with MDB React attached, for that matter) has the button work with a callback (that I personally changed to console.log) work as expected on my end, meaning one click = one firing of a function, on both Chrome and FF. What version of MDB React are you using? With Best Regards, Kuba

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: Yes
Tags