Skip to content

Commit

Permalink
fix(line): fix onMouseLeave firing
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr Pryshchepa authored and plouc committed May 10, 2020
1 parent 15bc0ee commit f2816f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions packages/line/src/Mesh.js
Expand Up @@ -19,6 +19,7 @@ const Mesh = ({
setCurrent,
onMouseEnter,
onMouseMove,
onMouseLeave,
onClick,
tooltip,
debug,
Expand Down Expand Up @@ -51,10 +52,14 @@ const Mesh = ({
[setCurrent, showTooltipAt, tooltip, onMouseMove]
)

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

const handleClick = useCallback(
(point, event) => {
Expand Down Expand Up @@ -85,6 +90,7 @@ Mesh.propTypes = {
setCurrent: PropTypes.func.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
4 changes: 2 additions & 2 deletions packages/voronoi/src/Mesh.js
Expand Up @@ -70,10 +70,10 @@ const Mesh = ({
if (currentIndex !== undefined && currentIndex !== null) {
previousNode = nodes[currentIndex]
}
onMouseLeave(previousNode, event)
previousNode && onMouseLeave(previousNode, event)
}
},
[setCurrentIndex]
[setCurrentIndex, currentIndex, nodes]
)
const handleClick = useCallback(
event => {
Expand Down

0 comments on commit f2816f4

Please sign in to comment.