Skip to content
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

[Tooltip] Fix tooltip visibility logic #1035

Merged
merged 2 commits into from Dec 13, 2021
Merged

[Tooltip] Fix tooltip visibility logic #1035

merged 2 commits into from Dec 13, 2021

Conversation

jjenzz
Copy link
Contributor

@jjenzz jjenzz commented Dec 13, 2021

A couple of fixes here so I've left comments inline to clarify what's what.

}
window.clearTimeout(openTimerRef.current);
Copy link
Contributor Author

@jjenzz jjenzz Dec 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I was a bit too trigger happy when refactoring everything into this onChange handler after the original PR feedback because this was only clearing if the open value changed from false to true (or vice versa) which is incorrect:

CleanShot.2021-12-13.at.14.43.37.mp4

When the mouse enters, the open timer starts but open is still false, then the mouse leaves which calls setOpen(false) and because that is the current value, the open timer wasn't cleared.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

});
})}
onFocus={composeEventHandlers(props.onFocus, () => {
if (!isMouseDownRef.current) context.onOpen();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explicitly only open if it isn't a mousedown focus.

@jjenzz jjenzz force-pushed the fix-tooltip branch 2 times, most recently from 8bafeef to 3e8d9e8 Compare December 13, 2021 15:09
}
window.clearTimeout(openTimerRef.current);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

packages/react/tooltip/src/Tooltip.tsx Show resolved Hide resolved
packages/react/tooltip/src/Tooltip.tsx Outdated Show resolved Hide resolved
@jjenzz jjenzz force-pushed the fix-tooltip branch 3 times, most recently from 70b594c to a1726e8 Compare December 13, 2021 17:19
@jjenzz jjenzz merged commit af1e766 into main Dec 13, 2021
@jjenzz jjenzz deleted the fix-tooltip branch December 13, 2021 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants