Repository navigation
fix(Tooltip): receive the open broadcast on document instead of window - #2869
Conversation
📝 WalkthroughWalkthroughThe tooltip open-event listener now uses ChangesTooltip event routing
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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
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. Comment |
commit: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/core/src/Tooltip/Tooltip.test.ts (1)
60-68: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftUse
@testing-library/vuefor the added regression test.The test uses
wrapper.find(...).trigger(...), which continues the@vue/test-utilsharness. As per coding guidelines, tests underpackages/core/src/**/*.test.tsshould use Vitest, jsdom,@testing-library/vue, andvitest-axe. Migrate this test, or confirm an approved exception forTooltip.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
📒 Files selected for processing (2)
packages/core/src/Tooltip/Tooltip.test.tspackages/core/src/Tooltip/TooltipContentImpl.vue
|
LGTM! Thanks for the PR @lazerg ! |
🔗 Linked issue
Fixes #2868
❓ Type of change
📚 Description
The "close the others when one opens" broadcast never actually ran.
TooltipRootdispatchesTOOLTIP_OPENondocument, butTooltipContentImpllistens for it onwindow. The event isn't set to bubble, and for something dispatched ondocument,windowonly 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
Summary by CodeRabbit
Bug Fixes
Tests