Fix how hovering tooltip is handled to keep tooltip open#1245
Fix how hovering tooltip is handled to keep tooltip open#1245gabrieljablonski merged 2 commits intomasterfrom
Conversation
WalkthroughThe changes update how the tooltip component handles mouse events. The event handler functions have been renamed to better reflect their behavior. Additionally, the logic for adding and removing event listeners was modified using a new conditional variable. This update alters when hover events are used to keep the tooltip open, ensuring a smoother interaction when moving between the anchor and the tooltip. Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
src/components/Tooltip/Tooltip.tsx:584
- Ensure that the condition for adding tooltip hover event listeners covers all intended cases. Verify that checking for both 'mouseout' and 'mouseleave' is correct when only adding 'mouseover' and 'mouseout' listeners.
const addHoveringTooltipListeners = clickable && (actualCloseEvents.mouseout || actualCloseEvents.mouseleave)
src/components/Tooltip/Tooltip.tsx:616
- Confirm that using the same 'addHoveringTooltipListeners' condition for removing event listeners is valid, especially if the tooltip configuration might change between setup and teardown.
if (addHoveringTooltipListeners) {
| tooltipRef.current?.addEventListener('mouseover', handleMouseOverTooltip) | ||
| tooltipRef.current?.addEventListener('mouseout', handleMouseOutTooltip) |
There was a problem hiding this comment.
Changed for consistency, since we favor mouseover/mouseout as the default hover events.
|
Beta version released with the last commit 🚀 or |
|
Beta version released with the last commit 🚀 or |
Closes #1226
Reproducible here: https://codesandbox.io/p/sandbox/tooltip-forked-sh299h
Hovering opens the tooltip with imperative mode, but unhovering closes it, which shouldn't happen.
Fixed here (beta version installed): https://codesandbox.io/p/devbox/tooltip-forked-y8ndp6
Summary by CodeRabbit