Skip to content

Commit

Permalink
fix(scatterplot): onMouseLeave not firing when mesh is used (#1064)
Browse files Browse the repository at this point in the history
Co-authored-by: Neil Kistner <neil.kistner@gmail.com>
  • Loading branch information
Shraymonks and wyze authored Jul 31, 2020
1 parent 565dc75 commit fb4aef0
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions packages/scatterplot/src/Mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ import { useTooltip } from '@nivo/tooltip'
import { Mesh as BaseMesh } from '@nivo/voronoi'
import { NodePropType } from './props'

const Mesh = ({ nodes, width, height, onMouseEnter, onMouseMove, onClick, tooltip, debug }) => {
const Mesh = ({
nodes,
width,
height,
onMouseEnter,
onMouseMove,
onMouseLeave,
onClick,
tooltip,
debug,
}) => {
const { showTooltipFromEvent, hideTooltip } = useTooltip()

const handleMouseEnter = useCallback(
Expand All @@ -31,9 +41,13 @@ const Mesh = ({ nodes, width, height, onMouseEnter, onMouseMove, onClick, toolti
[showTooltipFromEvent, tooltip, onMouseMove]
)

const handleMouseLeave = useCallback(() => {
hideTooltip()
}, [hideTooltip])
const handleMouseLeave = useCallback(
(node, event) => {
hideTooltip()
onMouseLeave && onMouseLeave(node, event)
},
[hideTooltip, onMouseLeave]
)

const handleClick = useCallback(
(node, event) => {
Expand Down Expand Up @@ -62,6 +76,7 @@ Mesh.propTypes = {
height: PropTypes.number.isRequired,
onMouseEnter: PropTypes.func,
onMouseMove: PropTypes.func,
onMouseLeave: PropTypes.func,
onClick: PropTypes.func,
tooltip: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired,
debug: PropTypes.bool.isRequired,
Expand Down

0 comments on commit fb4aef0

Please sign in to comment.