Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Fix Bug setting active hover to undefined

Open gleb-28 opened this issue 9 months ago • 2 comments

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/chart.js/dist/chart.js b/node_modules/chart.js/dist/chart.js
index e67f0ee..6021286 100644
--- a/node_modules/chart.js/dist/chart.js
+++ b/node_modules/chart.js/dist/chart.js
@@ -1029,6 +1029,7 @@ class DatasetController {
         }
     }
  _setStyle(element, index, mode, active) {
+        if (!element) return;
         element.active = active;
         const options = this.getStyle(index, active);
         this._resolveAnimations(index, mode, active).update(element, {

This issue body was partially generated by patch-package.

gleb-28 avatar Mar 11 '25 08:03 gleb-28

Do you also have a reproducible sample of this failing and crashing?

LeeLenaleee avatar Mar 11 '25 09:03 LeeLenaleee

Hi! Thank you for your response. The issue seems to occur occasionally, likely when the chart is being destroyed while the mouse is still hovering over it. Unfortunately, I haven't been able to reproduce it consistently, which makes it challenging to provide a sample.

gleb-28 avatar Mar 18 '25 08:03 gleb-28