Skip to content

fix(hover-card): portal content inside Theme scope (#1100)#2010

Open
kotAPI wants to merge 1 commit into
mainfrom
fix/issue-1100-hovercard-portal-theme
Open

fix(hover-card): portal content inside Theme scope (#1100)#2010
kotAPI wants to merge 1 commit into
mainfrom
fix/issue-1100-hovercard-portal-theme

Conversation

@kotAPI

@kotAPI kotAPI commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • HoverCard portal targets ThemeContext refs instead of DOM queries
  • Preserves optional explicit rootElement prop

Fixes #1100

Test plan

  • npm test -- --testPathPatterns=HoverCard.test

Summary by CodeRabbit

  • Refactor
    • Updated the Hover Card portal to resolve its root using the theme’s provided portal and container references first, with a simpler fallback to the document body. This improves consistency and reduces reliance on legacy DOM lookups for portal placement.
  • Tests
    • Added coverage to verify that HoverCard.Portal correctly renders its content into the configured theme portal root.

@changeset-bot

changeset-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 54f6dbe

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 19, 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: 0a047ae4-6a4e-4a68-b053-744e3791c95a

📥 Commits

Reviewing files that changed from the base of the PR and between 01a9067 and 54f6dbe.

📒 Files selected for processing (2)
  • src/components/ui/HoverCard/fragments/HoverCardPortal.tsx
  • src/components/ui/HoverCard/tests/HoverCard.portal.test.tsx
💤 Files with no reviewable changes (1)
  • src/components/ui/HoverCard/fragments/HoverCardPortal.tsx
✅ Files skipped from review due to trivial changes (1)
  • src/components/ui/HoverCard/tests/HoverCard.portal.test.tsx

📝 Walkthrough

Walkthrough

HoverCardPortal now resolves its portal root from themeContext refs instead of DOM queries. A new test verifies that HoverCard.Portal renders content into a provided portal root element.

Changes

HoverCardPortal Root Resolution

Layer / File(s) Summary
Portal root resolution via themeContext refs
src/components/ui/HoverCard/fragments/HoverCardPortal.tsx
The useEffect root resolution now prefers themeContext.portalRootRef.current, then themeContext.containerRef.current, then document.body, removing the prior DOM-query fallback chain.
Portal root rendering test
src/components/ui/HoverCard/tests/HoverCard.portal.test.tsx
A new test creates a portal root, provides it through ThemeContext.Provider, renders HoverCard.Portal, and asserts the content appears inside that root.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Possibly related PRs

  • rad-ui/ui#583: Introduced the original HoverCardPortal root-selection logic that this PR changes.
  • Directly linked issue #1100: Reports the same portal-root placement problem that this PR addresses.

Poem

🐇 I hop where the portal should bloom,
themeContext now points to the room.
No DOM maze to explore,
Just the right root and a little more!

🚥 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 is concise and matches the main fix: HoverCard portal content now renders inside the Theme scope.
Linked Issues check ✅ Passed The change routes portal content into ThemeContext refs and adds a test confirming it renders under the provided portal root.
Out of Scope Changes check ✅ Passed The PR is limited to the portal-root fix and a targeted test, with no clear unrelated changes.
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-hovercard-portal-theme

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

@kotAPI
kotAPI force-pushed the fix/issue-1100-hovercard-portal-theme branch from 01a9067 to 54f6dbe Compare June 24, 2026 05:11
@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 78.2% +0.00%
Branches 60.9% +0.05%
Functions 63.51% +0.00%
Lines 79.79% +0.00%

Coverage improved or stayed the same. Great job!

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.

BUG: Alert Dialog not spawning as a child to the provided root element

1 participant