Skip to content

Commit

Permalink
fix: do not delay show if tooltip is already shown (#676)
Browse files Browse the repository at this point in the history
  • Loading branch information
jth- committed Feb 26, 2021
1 parent 336aecc commit e8b9d84
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.js
Expand Up @@ -539,7 +539,6 @@ class ReactTooltip extends React.Component {
const { delayShow, disable } = this.state;
const { afterShow } = this.props;
const placeholder = this.getTooltipContent();
const delayTime = parseInt(delayShow, 10);
const eventTarget = e.currentTarget || e.target;

// Check if the mouse is actually over the tooltip, if so don't hide the tooltip
Expand All @@ -552,6 +551,8 @@ class ReactTooltip extends React.Component {
return;
}

const delayTime = !this.state.show ? parseInt(delayShow, 10) : 0;

const updateState = () => {
if (
(Array.isArray(placeholder) && placeholder.length > 0) ||
Expand All @@ -575,7 +576,7 @@ class ReactTooltip extends React.Component {
};

clearTimeout(this.delayShowLoop);
if (delayShow) {
if (delayTime) {
this.delayShowLoop = setTimeout(updateState, delayTime);
} else {
updateState();
Expand Down

0 comments on commit e8b9d84

Please sign in to comment.