Skip to content

Commit

Permalink
Merge pull request #22249 from huzaifa-99/19693-fix-tooltip-animation…
Browse files Browse the repository at this point in the history
…-canceling

Show visible tooltip after animation cancel
  • Loading branch information
robertjchen authored Jul 5, 2023
2 parents 4f9f428 + 9ea2f1e commit f9a8529
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/Tooltip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ class Tooltip extends PureComponent {
this.showTooltip = this.showTooltip.bind(this);
this.hideTooltip = this.hideTooltip.bind(this);
this.updateBounds = this.updateBounds.bind(this);
this.isAnimationCanceled = React.createRef(false);
}

// eslint-disable-next-line rulesdir/prefer-early-return
componentDidUpdate(prevProps) {
// if the tooltip text changed before the initial animation was finished, then the tooltip won't be shown
// we need to show the tooltip again
if (this.state.isVisible && this.isAnimationCanceled.current && this.props.text && prevProps.text !== this.props.text) {
this.isAnimationCanceled.current = false;
this.showTooltip();
}
}

/**
Expand Down Expand Up @@ -86,7 +97,9 @@ class Tooltip extends PureComponent {
duration: 140,
delay: 500,
useNativeDriver: false,
}).start();
}).start(({finished}) => {
this.isAnimationCanceled.current = !finished;
});
}
TooltipSense.activate();
}
Expand Down

0 comments on commit f9a8529

Please sign in to comment.