Skip to content

feat(ConfigProvider): add teleportTo for global default teleport target - #2714

Merged
zernonia merged 1 commit into
v2from
feat/config-provider-teleport-to
Jun 16, 2026
Merged

zernonia merged 1 commit into
v2from
feat/config-provider-teleport-to

Conversation

@zernonia

@zernonia zernonia commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

Closes #2225.

Summary

Adds a teleportTo prop to ConfigProvider so apps can set a single default Teleport target that every portalled primitive (Dialog, Popover, Tooltip, Menu, …) inherits — instead of passing to to each *Portal individually. This is primarily useful when rendering inside a custom element / shadow DOM.

Changes

  • ConfigProvider: new optional teleportTo?: string | HTMLElement prop, provided through the config context.
  • Teleport: resolves the target as to ?? config.teleportTo ?? 'body', so:
    • no config + no prop → 'body' (unchanged default),
    • config set → used as the default for all portals,
    • explicit to on a *Portal → still wins.
  • Tests covering the config-default path and the explicit-override path.
  • Regenerated the ConfigProvider API meta for the new prop.

Notes

Fully backwards compatible — the 'body' default is preserved when teleportTo is unset.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • ConfigProvider now supports a global teleportTo configuration option to set a default teleport target for portalled components
    • Teleport components prioritize explicit targets but fall back to the ConfigProvider configuration when no target is specified
  • Documentation

    • Updated ConfigProvider documentation with the new teleportTo prop details

…rget

Closes #2225. Adds a `teleportTo` prop on `ConfigProvider` that sets the
default Teleport target for every portalled primitive (Dialog, Popover,
Tooltip, …). `Teleport` now resolves `to ?? config.teleportTo ?? 'body'`,
so individual `*Portal` components can still override it via their own
`to` prop. Useful when rendering inside a custom element / shadow DOM.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a teleportTo prop to ConfigProvider that propagates a global default teleport target through Vue's provide/inject mechanism. Teleport.vue now resolves its target via a computed property: explicit to prop → ConfigProvider-injected teleportTo → 'body' fallback. Tests and documentation are included.

Changes

ConfigProvider teleportTo global default

Layer / File(s) Summary
ConfigProvider teleportTo prop and context provision
packages/core/src/ConfigProvider/ConfigProvider.vue, docs/content/meta/ConfigProvider.md
ConfigProviderContextValue and ConfigProviderProps gain an optional teleportTo field; default is undefined; the ref is provided via provideConfigProviderContext. Docs tables updated with prop description and string | HTMLElement type.
Teleport target resolution via context and tests
packages/core/src/Teleport/Teleport.vue, packages/core/src/Teleport/Teleport.test.ts
A computed target resolves from props.to, then injectConfigProviderContext teleportTo, then 'body'; the :to binding uses target. Two tests assert the fallback and override behaviors.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hop, hop, no more prop cascade!
One teleportTo in the provider laid,
Every portal finds its home with ease,
Computed targets floating on the breeze.
The rabbit nods — context well conveyed! ✨

🚥 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 clearly and specifically describes the main change: adding a teleportTo prop to ConfigProvider for establishing a global default teleport target.
Linked Issues check ✅ Passed The PR successfully implements the feature requested in #2225 by adding a teleportTo prop to ConfigProvider that establishes a global default teleport target, eliminating the need for repetitive per-component prop passing.
Out of Scope Changes check ✅ Passed All changes are directly aligned with the scope of adding teleportTo configuration to ConfigProvider; documentation, implementation, and tests all support this primary objective without extraneous modifications.
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 feat/config-provider-teleport-to

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

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

@pkg-pr-new

pkg-pr-new Bot commented Jun 16, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/reka-ui@2714

commit: 1178226

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/src/Teleport/Teleport.test.ts`:
- Around line 87-140: Replace the `@vue/test-utils` `mount` API with
`@testing-library/vue` `render` in both test cases (the test for ConfigProvider
teleportTo default and the test for explicit to prop override). Update the
component mounting pattern to use testing-library's render function and adjust
DOM queries accordingly. For both test cases, add axe accessibility checks after
mounting to verify the Teleport components meet accessibility standards. Update
the cleanup to use testing-library's unmount pattern and ensure all created DOM
containers are properly removed after each test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5912366c-513b-4427-9182-42dbae0e4e29

📥 Commits

Reviewing files that changed from the base of the PR and between fa5cf0e and 1178226.

📒 Files selected for processing (4)
  • docs/content/meta/ConfigProvider.md
  • packages/core/src/ConfigProvider/ConfigProvider.vue
  • packages/core/src/Teleport/Teleport.test.ts
  • packages/core/src/Teleport/Teleport.vue

@zernonia
zernonia merged commit 1b7c714 into v2 Jun 16, 2026
8 checks passed
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.

[Feature]: Add portal to ConfigProvider

1 participant