feat(react): use popover and anchor position API#178
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the popover and tooltip system to replace the @floating-ui/react library with native browser positioning APIs (Popover API and CSS Anchor Positioning). The changes simplify the implementation by removing portal logic and custom positioning libraries in favor of standard web platform features.
Key Changes:
- Removed dependency on
@floating-ui/reactand replaced it with native popover and anchor positioning APIs - Eliminated portal components (
Portal,Arrow) from both Tooltip and Popover, simplifying the component structure - Updated placement types to support
top,top-start, andtop-endalignments across HTML and React implementations
Reviewed Changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react/package.json | Removed @floating-ui/react dependency |
| packages/react/src/components/Tooltip.tsx | Complete reimplementation using native popover and anchor positioning APIs |
| packages/react/src/components/Popover.tsx | Complete reimplementation using native popover and anchor positioning APIs |
| packages/react/src/components/MediaContainer.tsx | Removed portal div and portalId prop |
| packages/html/src/media/media-container.ts | Removed portal slot from template |
| packages/html/src/elements/tooltip.ts | Updated placement types and alignment logic |
| packages/html/src/elements/popover.ts | Updated placement types and alignment logic |
| packages/react/src/skins/minimal/MinimalSkin.tsx | Removed Tooltip.Portal and Popover.Portal usage |
| packages/react/src/skins/frosted/FrostedSkin.tsx | Removed Tooltip.Portal and Popover.Portal usage |
| packages/react/src/skins/minimal/styles.ts | Added transparent background to popover popup |
| examples/react-demo/src/skins/minimal-eject/MinimalSkin.tsx | Removed portal usage |
| examples/react-demo/src/skins/frosted/FrostedSkin.tsx | Removed portal usage |
| examples/react-demo/src/skins/frosted-eject/FrostedSkin.tsx | Removed portal usage |
| examples/react-demo/src/skins/frosted-eject/frosted.css | Removed box-shadow and background properties |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const trigger = triggerRef.current; | ||
|
|
||
| popup.setAttribute('popover', 'manual'); | ||
| trigger.setAttribute('commandfor', popupId); |
There was a problem hiding this comment.
The attribute name 'commandfor' should be 'popovertarget' when using the Popover API. The 'commandfor' attribute is part of a different proposal.
| trigger.setAttribute('commandfor', popupId); | |
| trigger.setAttribute('popovertarget', popupId); |
| const trigger = triggerRef.current; | ||
|
|
||
| popup.setAttribute('popover', 'manual'); | ||
| trigger.setAttribute('commandfor', popupId); |
There was a problem hiding this comment.
The attribute name 'commandfor' should be 'popovertarget' when using the Popover API. The 'commandfor' attribute is part of a different proposal.
| trigger.setAttribute('commandfor', popupId); | |
| trigger.setAttribute('popovertarget', popupId); |
This pull request refactors how popover and tooltip portals are handled in the React demo skins and the core HTML/React packages. The main change is the removal of custom portal logic and the adoption of a simpler, more direct positioning approach for overlays. This reduces complexity, removes reliance on external libraries, and aligns the implementation across different skins and core components.
Popover & Tooltip Portal Refactoring
Tooltip.PortalandPopover.Portalin the React demo skins (FrostedSkin.tsx,MinimalSkin.tsx, etc.), simplifying the overlay rendering logic. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]media-container.ts), and the ReactMediaContainercomponent no longer includes aportalIdprop or portal div. [1] [2] [3]Positioning and Placement Improvements
top,top-start,top-end) and improved alignment logic, enabling more flexible positioning. [1] [2] [3] [4]@floating-ui/react. [1] [2] [3] [4]CSS and Style Adjustments
Dependency Clean-up
@floating-ui/reactfrom the React package dependencies, as it is no longer needed for popover/tooltip positioning.These changes make the overlay system more maintainable and consistent, while reducing reliance on external libraries and custom portal logic.