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

Legend event onLeave #10225

Closed
peteranderss0n opened this issue Mar 8, 2022 · 0 comments · Fixed by #10301
Closed

Legend event onLeave #10225

peteranderss0n opened this issue Mar 8, 2022 · 0 comments · Fixed by #10301

Comments

@peteranderss0n
Copy link

Expected behavior

When I place the mouse outside the legend I expect the onLeave event to be called all the time.

Current behavior

In the example at https://www.chartjs.org/docs/latest/samples/legend/events.html you can hover over a legend. If you quickly place the mouse outside the chart, content sometimes are highlight anyway due to onLeave isn't called.

On this image you can see that red are still highlighted, although the cursor are outside:
image

I added a console.log to the onHover and onLeave handler in the example and received this when the cursor is outside the the chart but the color are still highlighted:
image

Reproducible sample

https://codesandbox.io/s/react-chartjs-2-chart-js-issue-template-forked-3kw5p0?file=/src/App.tsx

Optional extra steps/info to reproduce

Drag the mouse between one of the legends and then up to the next. The problem occurs perhaps 1/10 times

image

Possible solution

While trying to find a fix for this, I played around with attaching a mouseout event, it worked better but I had problem cleaning up the eventlistener.

Context

No response

chart.js version

v3.7.1

Browser name and version

No response

Link to your project

No response

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.

2 participants