Skip to content

fix: do not delay show if tooltip is already shown #676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
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