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] Removing a dataset in onClick causes an error if the mouse is moved right after clicking #3791

Closed
rmja opened this issue Jan 13, 2017 · 2 comments · Fixed by #4840
Closed

Comments

@rmja
Copy link

rmja commented Jan 13, 2017

The problem happens because the lastActive array which is set here contains the active element which is removed in the onClick, so in the following mousemove event happening after the mouseup event fails because this line contains the removed element, and the call to updateHoverStyle() fails because the dataset is not present anymore.

Expected Behavior

It should be possible to remove a dataset within onClick() and move the mouse just after without any error.

Possible Solution

Update lastActive in the top of handleEvent so that it only includes elements which are still present on the chart.

This hack is a temporary workaround:

                   onHover: function(event, elements) {
                        if (self.chart.data.datasets.length === 0) {
                            this.active.length = 0;
                            this.lastActive.length = 0;
                        }
                    }
@etimberg
Copy link
Member

@rmja can you post a fiddle that reproduces this?

@timwis
Copy link

timwis commented Mar 15, 2017

I'm experiencing this as well. Here's a demo. To reproduce it, open your JavaScript console (not the one that comes with Codepen), then click on one of the bars. You'll see the second dataset disappear. If you then move your mouse, you'll see your console flooded with errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants