chartjs / chartjs/Chart.js

Timing of `chart.update('none')` causing hover state to get stuck

Open
#11,979 1 comment 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
JavaScript
Stars
67.7k
Forks
11.9k
Avg merge
7h 39m
Merged PRs (30d)
5

Description

### Expected behavior

Hovered elements should leave the hovered state when no longer hovered, even if an update is triggered without animations during the animation.

### Current behavior

Some elements get stuck in the hovered state, only recovering back to the unhovered state once another `chart.update('none')` call happens

### Reproducible sample

https://codepen.io/alexrcoleman/pen/JoPErdL

### Optional extra steps/info to reproduce

In this sample, a plugin triggers `chart.update('none')` when the mouse moves near the dataset. Move the mouse across the dataset to trigger the update while simultaneously triggering the hover state. I've attached a sample video showing the behavior; its fairly easy to repro a glitchy hover state lagging behind the cursor, but a bit more finicky to reach the bug where it actually gets stuck.

https://github.com/user-attachments/assets/1ab12a39-f873-4c19-b568-63821713475a

Note that I think this is a fairly minimal repro - the tooltip must be disabled or else moving the mouse causes updates that clear the bug. The points must have both a hoverBorderColor and hoverBackgroundColor set. The pointRadius/hoverPointRadius was not needed but makes the issue more apparent.

### Possible solution

_No response_

### Context

I have a plugin which highlights the hovered dataset by updating its color and calling `chart.update('none')` (using 'none' to avoid more expensive animation-based renders). This is causing points in the chart to get stuck in the hover state, looking really broken.

### chart.js version

latest

### Browser name and version

Chrome

### Link to your project

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.