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

fix: create separate handler instances for containers #2890

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/fresh-crabs-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"victory-native": patch
"victory-voronoi-container": patch
---

Fix: #2369 tooltips showing up inconsistently
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ VictoryVoronoiContainer.defaultEvents = (
? {}
: handler(event, { ...props, ...targetProps }, eventKey, context);

const voronioHelper = new VoronoiHelpers();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having a similar issue and need this fix too and came across this PR. Thanks for working on this!

One thing I noticed: doesn't this change break throttling though? We're now creating a new instance of the throttling function each time defaultEvents is called when VoronoiHelpers is instantiated.


return [
{
target: "parent",
eventHandlers: {
onTouchStart: createEventHandler(VoronoiHelpers.onMouseMove),
onTouchMove: createEventHandler(VoronoiHelpers.onMouseMove),
onTouchEnd: createEventHandler(VoronoiHelpers.onMouseLeave),
onTouchStart: createEventHandler(voronioHelper.onMouseMove),
onTouchMove: createEventHandler(voronioHelper.onMouseMove),
onTouchEnd: createEventHandler(voronioHelper.onMouseLeave),
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,16 @@ VictoryVoronoiContainer.defaultEvents = (
? {}
: handler(event, { ...props, ...targetProps }, eventKey, context);

const voronoiHelper = new VoronoiHelpers();

return [
{
target: "parent",
eventHandlers: {
onMouseLeave: createEventHandler(VoronoiHelpers.onMouseLeave),
onTouchCancel: createEventHandler(VoronoiHelpers.onMouseLeave),
onMouseMove: createEventHandler(VoronoiHelpers.onMouseMove),
onTouchMove: createEventHandler(VoronoiHelpers.onMouseMove),
onMouseLeave: createEventHandler(voronoiHelper.onMouseLeave),
onTouchCancel: createEventHandler(voronoiHelper.onMouseLeave),
onMouseMove: createEventHandler(voronoiHelper.onMouseMove),
onTouchMove: createEventHandler(voronoiHelper.onMouseMove),
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/victory-voronoi-container/src/voronoi-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,4 @@ class VoronoiHelpersClass {
});
}

export const VoronoiHelpers = new VoronoiHelpersClass();
export const VoronoiHelpers = VoronoiHelpersClass;