Skip to content

fix(Tooltip): receive the open broadcast on document instead of window - #2869

Merged
zernonia merged 1 commit into
unovue:v2from
lazerg:fix/issue-2868-tooltip-broadcast-document
Aug 13, 2026
Merged

zernonia merged 1 commit into
unovue:v2from
lazerg:fix/issue-2868-tooltip-broadcast-document

Conversation

@lazerg

@lazerg lazerg commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🔗 Linked issue

Fixes #2868

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

The "close the others when one opens" broadcast never actually ran. TooltipRoot dispatches TOOLTIP_OPEN on document, but TooltipContentImpl listens for it on window. The event isn't set to bubble, and for something dispatched on document, window only sees it during the capture phase, not the bubble phase the listener is registered for. So the handler was skipped every time.

This stayed hidden with a mouse because leaving one trigger already closes it before the pointer reaches the next one. It shows up as soon as a tooltip opens without a pointerleave in between, for example with touch input or a programmatic open.

Moved the listener to document, matching where the event is dispatched from.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Summary by CodeRabbit

  • Bug Fixes

    • Improved tooltip behavior so opening one tooltip correctly closes any tooltip that is already open.
    • Enhanced tooltip event handling for more reliable behavior across the application.
  • Tests

    • Added coverage for tooltip replacement behavior and improved test cleanup.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The tooltip open-event listener now uses document, matching the dispatch target. Tests verify that an open tooltip closes after TOOLTIP_OPEN and add wrapper cleanup with pending-promise flushing.

Changes

Tooltip event routing

Layer / File(s) Summary
Align event listener and regression coverage
packages/core/src/Tooltip/TooltipContentImpl.vue, packages/core/src/Tooltip/Tooltip.test.ts
TooltipContentImpl.vue listens for TOOLTIP_OPEN on document. Tests verify tooltip closure after the event and clean up mounted wrappers in both suites.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the Tooltip fix: listening for the open broadcast on document instead of window.
Linked Issues check ✅ Passed The change listens on document and adds coverage for closing an open tooltip when TOOLTIP_OPEN is dispatched.
Out of Scope Changes check ✅ Passed All changes support the linked Tooltip event-listener fix or its test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

@pkg-pr-new

pkg-pr-new Bot commented Aug 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/reka-ui@2869

commit: dd57e40

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/core/src/Tooltip/Tooltip.test.ts (1)

60-68: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Use @testing-library/vue for the added regression test.

The test uses wrapper.find(...).trigger(...), which continues the @vue/test-utils harness. As per coding guidelines, tests under packages/core/src/**/*.test.ts should use Vitest, jsdom, @testing-library/vue, and vitest-axe. Migrate this test, or confirm an approved exception for Tooltip.test.ts.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/Tooltip/Tooltip.test.ts` around lines 60 - 68, Update the
regression test in the Tooltip test suite to use `@testing-library/vue`
interactions and queries instead of the Vue Test Utils
wrapper.find(...).trigger(...) harness, while preserving the focus, broadcast,
and dismissal assertions; only retain the current approach if Tooltip.test.ts
has an approved exception.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/core/src/Tooltip/Tooltip.test.ts`:
- Around line 60-68: Update the regression test in the Tooltip test suite to use
`@testing-library/vue` interactions and queries instead of the Vue Test Utils
wrapper.find(...).trigger(...) harness, while preserving the focus, broadcast,
and dismissal assertions; only retain the current approach if Tooltip.test.ts
has an approved exception.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a993e415-63b3-45cb-ad3d-e7441b546856

📥 Commits

Reviewing files that changed from the base of the PR and between c23e0ed and dd57e40.

📒 Files selected for processing (2)
  • packages/core/src/Tooltip/Tooltip.test.ts
  • packages/core/src/Tooltip/TooltipContentImpl.vue

@zernonia

Copy link
Copy Markdown
Member

LGTM! Thanks for the PR @lazerg !

@zernonia
zernonia merged commit b32f255 into unovue:v2 Aug 13, 2026
7 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's one-at-a-time close never fires (TOOLTIP_OPEN dispatched on document, listened on window, non-bubbling)

2 participants