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

[Bug] Double invocation of onClick #19

Closed
jektvik opened this issue Apr 25, 2020 · 2 comments · Fixed by #26
Closed

[Bug] Double invocation of onClick #19

jektvik opened this issue Apr 25, 2020 · 2 comments · Fixed by #26
Labels
bug Something isn't working

Comments

@jektvik
Copy link

jektvik commented Apr 25, 2020

Version

1.1.0

Reproduction link

https://demos.creative-tim.com/black-dashboard-react/#/admin/dashboard

Operating System

windows

Device

pc

Browser & Version

Chrome Version 81.0.4044.113

Steps to reproduce

On the template dashboard click either of Accounts Purchases or Sessions
Debug the onClick handler and observe that on each of these buttons it fires twice

What is expected?

The onClick function should be invoked once

What is actually happening?

The onClick function is invoked twice


Solution

Removing input from inside the button component removes the problem but it also removes ui

Additional comments

@einazare einazare added question Further information is requested and removed question Further information is requested labels Apr 27, 2020
@einazare
Copy link
Contributor

Hello there, @jekusz ,

Thank you for your interest in working with our products.
Please go inside src/views/Dashboard.js and delete the following bits of code:

                          <input
                            defaultChecked
                            className="d-none"
                            name="options"
                            type="radio"
                          />
                          <input
                            className="d-none"
                            name="options"
                            type="radio"
                          />

And

                          <input
                            className="d-none"
                            name="options"
                            type="radio"
                          />

Alternatively, you can change the following code from:

  setBgChartData = name => {
    this.setState({
      bigChartData: name
    });
  };

to:

  setBgChartData = (event,name) => {
    event.preventDefault();
    this.setState({
      bigChartData: name
    });
  };

And the following codes:

onClick={() => this.setBgChartData("data1")}
onClick={() => this.setBgChartData("data2")}
onClick={() => this.setBgChartData("data3")}

To:

onClick={(e) => this.setBgChartData(e,"data1")}
onClick={(e) => this.setBgChartData(e,"data2")}
onClick={(e) => this.setBgChartData(e,"data3")}

Best,
Manu

@einazare einazare added the bug Something isn't working label Apr 27, 2020
@jektvik
Copy link
Author

jektvik commented Apr 27, 2020

I suppose the reason for the issue are the tags inside the elements. Though deleting them will remove some of the functionality they carry ? I like the preventDefault option better until it gets a good fix. Thanks!

einazare added a commit that referenced this issue Dec 11, 2020
einazare added a commit that referenced this issue Dec 11, 2020
einazare added a commit that referenced this issue Dec 11, 2020
einazare added a commit that referenced this issue Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants