Skip to content

fix(tooltip,hovercard): close when scrollable ancestor is scrolled#2557

Merged
zernonia merged 1 commit into
v2from
fix/tooltip-hovercard-hide-when-detached
Apr 1, 2026
Merged

fix(tooltip,hovercard): close when scrollable ancestor is scrolled#2557
zernonia merged 1 commit into
v2from
fix/tooltip-hovercard-hide-when-detached

Conversation

@zernonia

@zernonia zernonia commented Apr 1, 2026

Copy link
Copy Markdown
Member

🔗 Linked issue

Resolves #2543

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)

📚 Description

TooltipContent and HoverCardContent did not close when a scrollable ancestor container was scrolled — the floating element would stay open and appear visually detached from its trigger.

Root cause: scroll events do not bubble. A listener on window without { capture: true } only fires for page-level scroll (window/document), never for scrolls inside overflow containers.

Tooltip already had a window scroll listener with the right logic (target.contains(trigger)) — it just needed { capture: true } to intercept scrolls from inner containers.

HoverCard had no scroll handler at all — added the same pattern.

Changes:

  • TooltipContentImpl.vue — add { capture: true } to the existing useEventListener scroll call (one-character change)
  • HoverCardContentImpl.vue — add useEventListener(window, 'scroll', ..., { capture: true }) calling onDismiss() when the scrolled element contains the trigger

No new props, no new API surface, no dependency on getOverflowAncestors. The capture phase approach catches scroll from any ancestor container without needing to enumerate them.

📝 Checklist

  • I have linked an issue or discussion.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • HoverCards now automatically dismiss when scrolling occurs within the trigger area
  • Bug Fixes

    • Improved Tooltip scroll event detection for better reliability

Tooltip already had a window scroll listener but lacked `{ capture: true }`,
so it only fired for page-level scroll and missed scrolls on inner overflow
containers (scroll events don't bubble). HoverCard had no scroll handler at all.

Fixes #2543

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 21312092-b0f0-4bd2-be45-bc6dcf178079

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/tooltip-hovercard-hide-when-detached

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zernonia zernonia changed the base branch from main to v2 April 1, 2026 07:28
@zernonia zernonia merged commit a987ad5 into v2 Apr 1, 2026
3 checks passed
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.

[Bug]: Tooltip does not close when a scrollable ancestor is scrolled

1 participant