Skip to content

fix(Popover): primitive portal via Theme refs (#1100)#2060

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

fix(Popover): primitive portal via Theme refs (#1100)#2060
kotAPI wants to merge 1 commit into
mainfrom
fix/issue-1100-popover-primitive-portal

Conversation

@kotAPI

@kotAPI kotAPI commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

PopoverPrimitivePortal now resolves portal root through Theme refs instead of querySelector.\n\nFixes #1100

Summary by CodeRabbit

  • Bug Fixes
    • Improved where popover content is rendered, making portal behavior more reliable across app layouts.
    • Popover content now consistently appears in the expected portal container when opened.
  • Tests
    • Added coverage for popover portal rendering to help prevent regressions.

@changeset-bot

changeset-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 56777e9

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

📝 Walkthrough

Walkthrough

PopoverPrimitivePortal drops two document.querySelector DOM lookups from its rootElementRef fallback chain, replacing them with direct ref access via themeContext. A new test file verifies that portaled popover content renders inside the [data-rad-ui-portal-root] element after the trigger is clicked.

Changes

Popover Portal Root Resolution

Layer / File(s) Summary
Portal root fallback chain + test
src/core/primitives/Popover/fragments/PopoverPrimitivePortal.tsx, src/components/ui/Popover/tests/Popover.portal.test.tsx
rootElementRef.current now resolves via container prop → themeContext.portalRootRef.currentthemeContext.containerRef.currentdocument.body, removing the prior document.querySelector('[data-rad-ui-portal-root]') and document.querySelector('#rad-ui-theme-container') lookups. The new test renders a Theme-wrapped Popover with Popover.Portal, clicks the trigger, and asserts the portaled content appears inside the [data-rad-ui-portal-root] element.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

codex

Suggested reviewers

  • mrkazmi333

Poem

🐇 Hop, hop, no more querySelector hoops to leap,
The portal root is found in refs, clean and neat!
Context refs chain like carrots in a row,
document.body waits below as a gentle fallback glow.
The test clicks, the popover pops — all correct,
This bunny's code garden is tidy and perfect! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: Popover portal root resolution now uses Theme refs instead of DOM queries.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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-primitive-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 78.2% +0.00%
Branches 60.82% -0.03%
Functions 63.51% +0.00%
Lines 79.79% +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