fix: Close tooltip when cursor leaves chart via y-axis#4350
Open
fix: Close tooltip when cursor leaves chart via y-axis#4350
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4350 +/- ##
==========================================
- Coverage 97.44% 97.43% -0.01%
==========================================
Files 897 901 +4
Lines 26395 26454 +59
Branches 9525 9531 +6
==========================================
+ Hits 25721 25776 +55
- Misses 668 672 +4
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When hovering over a line chart and moving the cursor toward the y-axis labels, the tooltip stays open even after the cursor has completely left the chart area.
Root cause
Two issues in
onSVGMouseOutandonPopoverLeave:onSVGMouseOutused a coordinate-basedisMouseOverPopovercheck with a 12px deadzone around the popover's bounding rect. When the popover is positioned near the y-axis, the cursor's exit coordinates often fell within this deadzone — causing cleanup to be skipped.onPopoverLeaveonly cleared highlights when the mouse moved back into the SVG (nodeContains(svg, relatedTarget)). When the mouse exited the popover toward the outside (y-axis exit path), nothing cleared the tooltip.Solution
onSVGMouseOut: Replaced the coordinate-basedisMouseOverPopovercheck with a DOM-basednodeContainscheck usingpopoverRef.current?.parentElement(which includes the transition wrapper). Cleanup is only suppressed when the mouse actually enters the popover DOM tree.onPopoverLeave: Simplified to unconditionally clear highlights when the mouse leaves the popover (unless handlers are disabled). When mouse returns to the SVG,onSVGMouseMovenaturally re-triggers the correct tooltip.The
isMouseOverPopoverdeadzone check is preserved inonSVGMouseMovewhere it remains useful for preventing tooltip flickering.Changes
src/mixed-line-bar-chart/hooks/use-mouse-hover.ts— UpdatedonSVGMouseOutandonPopoverLeavesrc/mixed-line-bar-chart/__tests__/use-mouse-hover.test.ts— Updated and added tests for both changesBefore:
Bildschirmaufnahme.2026-03-13.um.15.18.11.mov
After:
Bildschirmaufnahme.2026-03-13.um.15.18.31.mov
Related links, issue #, if available: n/a
How has this been tested?
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.