Skip to content

fix(Tooltip): portal via Theme refs without querySelector (#1100)#2040

Open
kotAPI wants to merge 1 commit into
mainfrom
fix/issue-1100-tooltip-content-portal
Open

fix(Tooltip): portal via Theme refs without querySelector (#1100)#2040
kotAPI wants to merge 1 commit into
mainfrom
fix/issue-1100-tooltip-content-portal

Conversation

@kotAPI

@kotAPI kotAPI commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Removes document querySelector fallbacks from TooltipContent portal resolution and adds Theme portal tests.\n\nCloses #1100

Summary by CodeRabbit

  • Refactor

    • Updated Tooltip positioning and container resolution logic
  • Tests

    • Added comprehensive test coverage for Tooltip behavior in different container scenarios

@changeset-bot

changeset-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e368649

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

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1d2d33de-7167-4651-a114-fe4bd30cb933

📥 Commits

Reviewing files that changed from the base of the PR and between fe87b36 and e368649.

📒 Files selected for processing (2)
  • src/components/ui/Tooltip/fragments/TooltipContent.tsx
  • src/components/ui/Tooltip/tests/Tooltip.portal.test.tsx

📝 Walkthrough

Walkthrough

TooltipContent portal root resolution is simplified by removing document.querySelector fallbacks for [data-rad-ui-portal-root] and #rad-ui-theme-container. Portal root now comes exclusively from themeContext?.portalRootRef.current or themeContext?.containerRef.current, falling back to undefined. A new test suite covers all three portal placement paths.

Changes

Tooltip Portal Root Resolution

Layer / File(s) Summary
Remove DOM-query fallbacks from portal root resolution
src/components/ui/Tooltip/fragments/TooltipContent.tsx
portalRoot derivation drops document.querySelector calls for [data-rad-ui-portal-root] and #rad-ui-theme-container; now resolves to themeContext?.portalRootRef.current, then themeContext?.containerRef.current, or undefined.
Tests for portal mounting scenarios
src/components/ui/Tooltip/tests/Tooltip.portal.test.tsx
Three tests cover: tooltip portals into ThemeContext.portalRootRef when set; falls back to ThemeContext.containerRef when portalRootRef is absent; explicit container prop on Tooltip.Content overrides both theme refs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • rad-ui/ui#1018: Modifies TooltipContent.tsx directly, changing how ThemeContext is accessed and handled in the same component this PR edits.

Suggested labels

automerge

🐇 No more querySelector in the night,
ThemeContext refs now guide the flight.
portalRoot blooms from context's hand,
Or undefined — just as planned.
Three tests confirm the portal's right!

🚥 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 accurately describes the main change: removing querySelector fallbacks from Tooltip portal resolution and using Theme refs instead.
Linked Issues check ✅ Passed The PR addresses issue #1100 by refactoring portal resolution to use Theme context refs instead of DOM queries, which aligns with the requirement to use proper Theme references for portal rendering.
Out of Scope Changes check ✅ Passed All changes are directly related to the portal resolution objective: TooltipContent refactoring to use Theme refs, and comprehensive test coverage for the three portal scenarios.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-1100-tooltip-content-portal

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

@github-actions

Copy link
Copy Markdown
Contributor

Coverage

This report compares the PR with the base branch. "Δ" shows how the PR affects each metric.

Metric PR Δ
Statements 75.73% +0.00%
Branches 59.14% -0.03%
Functions 61.75% +0.00%
Lines 77.26% +0.00%

Coverage decreased for at least one metric. Please add or update tests to improve coverage.

Run npm run coverage:ci locally for detailed reports and target untested areas to raise these numbers.

@kotAPI

kotAPI commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator Author

Code review

LGTM. Matches project patterns for portal Theme refs, Floating UI prop merge, controlled-switch/lazy-mount/RTL tests, or focused bug fixes. No changes requested.

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.

1 participant