plouc / nivo

nivo provides a rich set of dataviz components, built on top of the awesome d3 and React libraries
https://nivo.rocks
MIT License
13.2k stars 1.03k forks source link

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

Open NatiG100 opened 5 months ago

NatiG100 commented 5 months ago

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

Steps to reproduce the behavior:

  1. Create ResponsiveChoroplethchart
  2. Assign a function to the onMouseEnterand/or onMouseLeaveproperties
  3. Move the mouse over the chart, and from line to line, from point to point
  4. both onMouseEnterand onMouseLeaveare never fired

Expected behavior onMouseEntershould be fired every time the cursor moves to a new area; onMouseLeaveis fired every time the cursor leaves a area.

Desktop (please complete the following information):

Eykam commented 4 months ago

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.