Skip to content

[BUG] Removing a dataset in onClick causes an error if the mouse is moved right after clicking #3791

@rmja

Description

@rmja

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;
                        }
                    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions