Skip to content

refactor: Move TooltipProvider to ui-client package, reimplement document references and deduplicate portals#40392

Merged
dionisio-bot[bot] merged 4 commits into
developfrom
chore/tooltipProvider
May 5, 2026
Merged

refactor: Move TooltipProvider to ui-client package, reimplement document references and deduplicate portals#40392
dionisio-bot[bot] merged 4 commits into
developfrom
chore/tooltipProvider

Conversation

@gabriellsh
Copy link
Copy Markdown
Member

@gabriellsh gabriellsh commented May 4, 2026

Proposed changes (including videos or screenshots)

TooltipProvider directly references document global object, which restricts the usage of tooltips to the main window. In case the UI is rendered in a different document (through react portals in a popup window for example), no tooltips show, as events are not attached to the correct body, nor are the portals being rendered on the correct document.

In order to fix this, three things were changed:

  • TooltipProvider was moved to ui-client package, allowing for reuse in other places.
  • TooltipProvider was updated to accept an ownerDocument property, which should be the targetted document that will render the tooltips.
  • TooltipPortal was removed and deleted from the codebase. Under the hood, TooltipPortal uses the AnchorPortal element (with its own issues of document referencing), although TooltipComponent already is a portal since it uses Position component from fuselage, which implements its own portal. Check feat(fuselage): Implement OwnerDocument context and update document references fuselage#1947 for more information on how that issue was solved in the fuselage package.

Extra: Solved no-unused-expressions lint warning.

Issue(s)

SSGA-11

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Refactor
    • Restructured tooltip infrastructure to improve flexibility and support for custom document contexts, enabling better compatibility with portals and iframes.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented May 4, 2026

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 4, 2026

⚠️ No Changeset found

Latest commit: ef8aa66

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9ac0f0f0-592f-4672-924a-6cd9cbc0a728

📥 Commits

Reviewing files that changed from the base of the PR and between 5906dac and 5bb44c6.

📒 Files selected for processing (4)
  • apps/meteor/client/portals/TooltipPortal.tsx
  • apps/meteor/client/providers/MeteorProvider.tsx
  • packages/ui-client/src/providers/TooltipProvider.tsx
  • packages/ui-client/src/providers/index.ts
💤 Files with no reviewable changes (1)
  • apps/meteor/client/portals/TooltipPortal.tsx
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: 🔎 Code Check / TypeScript
  • GitHub Check: 🔎 Code Check / Code Lint
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • GitHub Check: 📦 Meteor Build (coverage)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • packages/ui-client/src/providers/index.ts
  • apps/meteor/client/providers/MeteorProvider.tsx
  • packages/ui-client/src/providers/TooltipProvider.tsx
🧠 Learnings (3)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • packages/ui-client/src/providers/index.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • packages/ui-client/src/providers/index.ts
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • apps/meteor/client/providers/MeteorProvider.tsx
  • packages/ui-client/src/providers/TooltipProvider.tsx
🔇 Additional comments (1)
packages/ui-client/src/providers/TooltipProvider.tsx (1)

10-13: Verify popup roots mount a document-scoped provider.

React portals preserve context, so popup content rendered from the main tree will still use this provider instance. If no nested <TooltipProvider ownerDocument={popup.document}> is mounted in the popup root, the handlers remain attached to window.document.body, and hover/click events inside the popup will never reach this effect.

Also applies to: 129-139


Walkthrough

The TooltipPortal component is removed and its rendering logic is integrated into TooltipProvider. The provider now accepts an optional ownerDocument prop to support custom document contexts and attaches event listeners directly to that document's body. The TooltipProvider export is added to the public API barrel file, and MeteorProvider now imports it from the UI client package.

Changes

Tooltip Portal Consolidation

Layer / File(s) Summary
Core Provider Update
packages/ui-client/src/providers/TooltipProvider.tsx
TooltipProvider adds optional ownerDocument prop (defaults to window.document), attaches mouseover and click listeners to ownerDocument.body, removes TooltipPortal wrapper, and renders tooltip directly. Title restoration logic refactored with explicit if (previousAnchor) checks.
Portal Component Removal
apps/meteor/client/portals/TooltipPortal.tsx
TooltipPortal component and its AnchorPortal wrapper deleted entirely.
Public API Export
packages/ui-client/src/providers/index.ts
TooltipProvider added as named re-export from ./TooltipProvider.
Provider Integration
apps/meteor/client/providers/MeteorProvider.tsx
TooltipProvider import changed from local ./TooltipProvider module to @rocket.chat/ui-client package export.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

type: feature

🚥 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 pull request title accurately reflects the main changes: moving TooltipProvider to ui-client, reimplementing document references via the ownerDocument prop, and removing the redundant TooltipPortal.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • SSGA-11: Request failed with status code 401

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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

@gabriellsh gabriellsh marked this pull request as ready for review May 4, 2026 16:40
@gabriellsh gabriellsh requested a review from a team as a code owner May 4, 2026 16:40
@coderabbitai coderabbitai Bot added the type: feature Pull requests that introduces new feature label May 4, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.98%. Comparing base (6cb6b27) to head (ef8aa66).
⚠️ Report is 4 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40392      +/-   ##
===========================================
- Coverage    70.00%   69.98%   -0.03%     
===========================================
  Files         3301     3299       -2     
  Lines       120462   120390      -72     
  Branches     21566    21620      +54     
===========================================
- Hits         84330    84255      -75     
- Misses       32834    32848      +14     
+ Partials      3298     3287      -11     
Flag Coverage Δ
e2e 59.62% <ø> (-0.01%) ⬇️
e2e-api 46.26% <ø> (+<0.01%) ⬆️
unit 70.83% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@dougfabris dougfabris left a comment

Choose a reason for hiding this comment

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

LGTM!

@gabriellsh gabriellsh added stat: QA assured Means it has been tested and approved by a company insider type: improvement and removed type: feature Pull requests that introduces new feature labels May 4, 2026
@dougfabris dougfabris added this to the 8.5.0 milestone May 4, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label May 4, 2026
@gabriellsh gabriellsh removed the stat: QA assured Means it has been tested and approved by a company insider label May 5, 2026
@dionisio-bot dionisio-bot Bot removed the stat: ready to merge PR tested and approved waiting for merge label May 5, 2026
@gabriellsh gabriellsh added the stat: QA assured Means it has been tested and approved by a company insider label May 5, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label May 5, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue May 5, 2026
Merged via the queue into develop with commit 09cb83c May 5, 2026
81 of 84 checks passed
@dionisio-bot dionisio-bot Bot deleted the chore/tooltipProvider branch May 5, 2026 16:21
ggazzo pushed a commit that referenced this pull request May 5, 2026
…document references and deduplicate portals (#40392)

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants