From a541bfb5e2c23129ad02813544db7c559e1946bd Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 30 Jan 2018 14:12:02 -0330 Subject: [PATCH] Trigger a handleMouseMove() call after title changes to recalculate the position of the tooltip. --- src/Tooltip.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Tooltip.js b/src/Tooltip.js index f883442..fc4fd71 100644 --- a/src/Tooltip.js +++ b/src/Tooltip.js @@ -40,9 +40,12 @@ class Tooltip extends React.Component { this.componentEl.addEventListener('mouseleave', this.handleMouseOut); }; - componentDidUpdate = () => { + componentDidUpdate = (prevProps) => { this.tooltipEl.className = 'tooltip ' + this.props.position; this.tooltipEl.childNodes[1].textContent = this.props.title; + if (prevProps.title !== this.props.title) { + this.handleMouseMove(); + } };