Skip to content

Conversation

@metonym
Copy link
Collaborator

@metonym metonym commented Apr 13, 2025

Adds Portal and FloatingPortal components to enable rendering content outside the normal DOM hierarchy.

This addresses z-index stacking context issues and provides a foundation for auto-positioning menus, tooltips, and modals. The Portal component renders content into a fixed container appended to document.body, while FloatingPortal extends this with automatic positioning relative to a reference element using the Floating UI library.

TODO:

Eventual usage:

  • Apply to Tooltip
  • Apply to Toggletip
  • Apply to Popover
  • Apply to ListBox

Why?

Currently, "popover" elements (dropdown menus, tooltips, modals, etc) are relatively positioned, meaning that the element is contained within the component in the DOM. This causes z-index issues, where other elements may obstruct menus. Additionally, elements may be cut off if an ancestor component manipulates overflow: hidden.

See issues tagged with "portal": https://github.com/carbon-design-system/carbon-components-svelte/issues?q=is%3Aissue%20state%3Aopen%20label%3Aportal

This is where a portal helps. It's a standard feature of UI, where "popover" elements are "portalled" outside of the root node for the main application. The portalled node is typically a sibling of the app node.

Proposed Changes

  • Breaking change: apply a floating portal approach to all "popover" elements.
  • Feature: add Portal and FloatingPortal components.

@metonym metonym force-pushed the floating-portal branch from f8e5348 to 1ddd9ba Compare May 28, 2025 15:57
@metonym metonym force-pushed the master branch 3 times, most recently from 234c1f9 to e774974 Compare October 28, 2025 20:48
@metonym metonym force-pushed the floating-portal branch 7 times, most recently from 2d75062 to af2192d Compare November 30, 2025 18:26
@metonym metonym changed the title feat(portal): support portal feat(portal): add Portal and FloatingPortal components Nov 30, 2025
@metonym metonym changed the title feat(portal): add Portal and FloatingPortal components feat(portal): add FloatingPortal component Nov 30, 2025
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.

PasswordInput causes overflow-x in Modal Possible CSS glitch with CodeSnippet

1 participant