Skip to content

feat(react): use popover and anchor position API#178

Merged
luwes merged 1 commit intomainfrom
react-popover-anchor-api
Nov 11, 2025
Merged

feat(react): use popover and anchor position API#178
luwes merged 1 commit intomainfrom
react-popover-anchor-api

Conversation

@luwes
Copy link
Copy Markdown
Collaborator

@luwes luwes commented Nov 11, 2025

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

  • Removed all usages of Tooltip.Portal and Popover.Portal in 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]
  • Removed portal slot and related logic from the HTML media container template (media-container.ts), and the React MediaContainer component no longer includes a portalId prop or portal div. [1] [2] [3]

Positioning and Placement Improvements

  • Updated the popover and tooltip core HTML elements to support new placement values (top, top-start, top-end) and improved alignment logic, enabling more flexible positioning. [1] [2] [3] [4]
  • Synced the React popover/tooltip types and context to match the new placement values and removed dependencies on @floating-ui/react. [1] [2] [3] [4]

CSS and Style Adjustments

  • Updated popover popup styles in the frosted skin CSS to remove transparent backgrounds and box shadows, further simplifying overlay appearance.

Dependency Clean-up

  • Removed @floating-ui/react from 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.

@luwes luwes requested a review from Copilot November 11, 2025 00:29
@luwes luwes self-assigned this Nov 11, 2025
@vercel
Copy link
Copy Markdown

vercel bot commented Nov 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
vjs-10-demo-html Ready Ready Preview Comment Nov 11, 2025 0:29am
vjs-10-demo-next Ready Ready Preview Comment Nov 11, 2025 0:29am
vjs-10-demo-react Ready Ready Preview Comment Nov 11, 2025 0:29am
vjs-10-website Ready Ready Preview Comment Nov 11, 2025 0:29am

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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/react and 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, and top-end alignments 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);
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

The attribute name 'commandfor' should be 'popovertarget' when using the Popover API. The 'commandfor' attribute is part of a different proposal.

Suggested change
trigger.setAttribute('commandfor', popupId);
trigger.setAttribute('popovertarget', popupId);

Copilot uses AI. Check for mistakes.
const trigger = triggerRef.current;

popup.setAttribute('popover', 'manual');
trigger.setAttribute('commandfor', popupId);
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

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

The attribute name 'commandfor' should be 'popovertarget' when using the Popover API. The 'commandfor' attribute is part of a different proposal.

Suggested change
trigger.setAttribute('commandfor', popupId);
trigger.setAttribute('popovertarget', popupId);

Copilot uses AI. Check for mistakes.
Comment thread packages/react/src/components/Tooltip.tsx
Comment thread packages/react/src/components/Popover.tsx
@luwes luwes merged commit f513c74 into main Nov 11, 2025
7 checks passed
@luwes luwes deleted the react-popover-anchor-api branch November 11, 2025 18:28
@github-actions github-actions bot mentioned this pull request Nov 11, 2025
@github-actions github-actions bot mentioned this pull request Feb 26, 2026
@github-actions github-actions bot mentioned this pull request Mar 10, 2026
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.

2 participants