From 0adc2884d1114920926f33c066867a0c13e47796 Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed Date: Wed, 5 Jul 2023 13:49:27 +0500 Subject: [PATCH 1/2] show visible tooltip after animation cancel --- src/components/Tooltip/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/Tooltip/index.js b/src/components/Tooltip/index.js index 2e5291ca271d..340a5cda1c9a 100644 --- a/src/components/Tooltip/index.js +++ b/src/components/Tooltip/index.js @@ -45,6 +45,16 @@ 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); + } + + 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(); + } } /** @@ -86,7 +96,9 @@ class Tooltip extends PureComponent { duration: 140, delay: 500, useNativeDriver: false, - }).start(); + }).start(({finished}) => { + this.isAnimationCanceled.current = !finished; + }); } TooltipSense.activate(); } From 9ea2f1e963c48dcee1e1dc51ff9a13b046dba09d Mon Sep 17 00:00:00 2001 From: Huzaifa Rasheed <68777211+huzaifa-99@users.noreply.github.com> Date: Wed, 5 Jul 2023 14:14:34 +0500 Subject: [PATCH 2/2] Fix lint --- src/components/Tooltip/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Tooltip/index.js b/src/components/Tooltip/index.js index 340a5cda1c9a..0454327de284 100644 --- a/src/components/Tooltip/index.js +++ b/src/components/Tooltip/index.js @@ -48,6 +48,7 @@ class Tooltip extends PureComponent { 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