Skip to content

fix(popover): portal content inside Theme scope (#1100)#2011

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

fix(popover): portal content inside Theme scope (#1100)#2011
kotAPI wants to merge 1 commit into
mainfrom
fix/issue-1100-popover-portal-theme

Conversation

@kotAPI

@kotAPI kotAPI commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Popover portal targets ThemeContext refs instead of querySelector
  • Keeps optional container prop support

Fixes #1100

Test plan

  • npm test -- --testPathPatterns=Popover.test

Summary by CodeRabbit

  • Refactor
    • Simplified internal portal element selection logic for Popover components, reducing complexity and improving code maintainability.

Use ThemeContext portalRootRef and containerRef instead of
querySelector for theme-scoped portaling.

Fixes #1100
@changeset-bot

changeset-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c24b931

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: 6973a512-0008-4b58-8f34-4895e0803b98

📥 Commits

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

📒 Files selected for processing (1)
  • src/core/primitives/Popover/fragments/PopoverPrimitivePortal.tsx

📝 Walkthrough

Walkthrough

In PopoverPrimitivePortal, the fallback chain for rootElementRef.current is simplified from six steps to four: container prop → themeContext.portalRootRef.currentthemeContext.containerRef.currentdocument.body. The two DOM query-based fallbacks (querySelector('[data-rad-ui-portal-root]') and querySelector('#rad-ui-theme-container')) are removed.

Changes

Portal root fallback simplification

Layer / File(s) Summary
Remove DOM query fallbacks from portal root selection
src/core/primitives/Popover/fragments/PopoverPrimitivePortal.tsx
rootElementRef.current assignment drops the querySelector calls for [data-rad-ui-portal-root] and #rad-ui-theme-container, leaving only container, themeContext.portalRootRef.current, themeContext.containerRef.current, and document.body in the fallback chain.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • rad-ui/ui#470: Directly related — also changes portal root selection logic (in AlertDialogPortal) by introducing a context-driven fallback to document.body, the same pattern this PR consolidates in PopoverPrimitivePortal.

Poem

🐇 No more hunting the DOM for roots so deep,
A shorter chain now lets the portal leap!
portalRootRef, containerRef, body at last,
The querySelector queries are now in the past.
Hop hop, simplicity wins the race! 🌿

🚥 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 PR title clearly summarizes the main change: fixing portal content placement within Theme scope for the Popover component.
Linked Issues check ✅ Passed The PR addresses the core requirement from #1100 by replacing querySelector-based portal resolution with ThemeContext refs to ensure portals render within the Theme scope.
Out of Scope Changes check ✅ Passed The changes are strictly focused on fixing PopoverPrimitivePortal's root element resolution and directly align with the issue's objective.
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-popover-portal-theme

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

@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.

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

1 participant