Repository navigation
fix(Bar): pass the original data index to sparse bar mouse events - #7929
Conversation
Signed-off-by: Charan Rathore <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughBar rectangle and background mouse event handlers now receive each entry’s original data index. Tests cover five mouse events when sparse data causes the first bar to be skipped. ChangesBar sparse-data events
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to Bar mouse callbacks will now report the original data index when bars are skipped for sparse data. This matches the other Bar callbacks, and no merge-blocking risk was found. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Bundle ReportChanges will increase total bundle size by 168 bytes (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: recharts/bundle-es6Assets Changed:
view changes for bundle: recharts/bundle-treeshaking-cartesianAssets Changed:
view changes for bundle: recharts/bundle-cjsAssets Changed:
view changes for bundle: recharts/bundle-umdAssets Changed:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7929 +/- ##
=======================================
Coverage 88.97% 88.97%
=======================================
Files 647 647
Lines 15872 15872
Branches 4172 4172
=======================================
Hits 14122 14122
Misses 1556 1556
Partials 194 194 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Test Results SummaryThis comment shows the latest test results for this pull request.
ℹ️ About Flakiness.io in GitHubYour team has set up Flakiness.io pull request comments. This comment is updated when
Flakiness.io rewrites the comment in place, so it always reflects the most recently tested commit. |
|
This is green on CI and conflict-free on my end. Is there anything you'd like changed before it can land? Happy to adjust. |
Description
When a bar is skipped (for example a zero value), the rendered rectangles no longer line up with the data array by position. Two
adaptEventsOfChildcall sites inBar.tsxbindonMouseMove,onMouseDown,onMouseUp,onMouseOverandonMouseOutwith the rendered positioni, so those handlers receive the wrong index and payload for sparse data. The siblingonClick/onMouseEnter/onMouseLeavehandlers already useentry.originalDataIndex.This change passes
entry.originalDataIndexat both call sites (the bar rectangle and the background rectangle), making all eight callbacks consistent.A new spec
test/cartesian/Bar.sparseEvents.spec.tsxadds 10 parameterized cases: for both the bar and the background rectangle, each of the five affected events must receive the original data index and the matching payload.Related Issue
Fixes #7928
Motivation and Context
Consumers reading the index argument of these callbacks (to look up the datum, sync external state, etc.) get the wrong entry whenever any bar is skipped, and the behavior disagrees with the click handler on the same rectangle.
How Has This Been Tested?
main(10/10 red: handlers receive index 0 and category A's payload for the category B rectangle) and pass with the change (10/10 green).Bar.sparseEvents.spec.tsx,Bar/Bar.spec.tsx,BarChart.spec.tsx,BarStack.spec.tsx- 253 tests green.test/polar/Pie/Pie.typed.spec.tsxduring a window overlapping a heap-heavy typecheck; that spec passes 5/5 on isolated reruns against both unpatchedmain(119ms) and this change (120ms), so the timeouts are resource contention, but a clean full-suite run is not claimed.Screenshots (if appropriate):
N/A
Types of changes
Checklist:
This change was prepared with AI assistance and verified locally as described above.
Summary by CodeRabbit