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

onMouseEnter and onMouseLeave don't work on @nivo/geo #2598

Open
NatiG100 opened this issue May 30, 2024 · 1 comment
Open

onMouseEnter and onMouseLeave don't work on @nivo/geo #2598

NatiG100 opened this issue May 30, 2024 · 1 comment

Comments

@NatiG100
Copy link

Describe/explain the bug
onMouseEnter and onMouseLeave don't work on @nivo/geo(both events are not fired).

Steps to reproduce the behavior:

  1. Create ResponsiveChoropleth chart
  2. Assign a function to the onMouseEnter and/or onMouseLeave properties
  3. Move the mouse over the chart, and from line to line, from point to point
  4. both onMouseEnter and onMouseLeave are never fired

Expected behavior
onMouseEnter should be fired every time the cursor moves to a new area; onMouseLeave is fired every time the cursor leaves a area.

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Chrome
  • Version: 125.0.6422.78 (Official Build) (64-bit)
@Eykam
Copy link

Eykam commented Jul 11, 2024

I had the same issue, so I went to look through the source code.

It seems like this is why that behavior exists:
https://github.com/plouc/nivo/blob/master/packages/geo/src/Choropleth.js#L89-L102

Idk if was intentionally written like this, but the handleMouse* event handlers' default behavior is toggling the tooltip. The event handler props passed to don't actually overload these defaults.

Should be a pretty simple to fix in the source code. You'd just have to destructure the custom handleMouse* events from the props. If its defined, use it as the event handler, otherwise use the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants