Skip to content

feat: use popover API, add safe polygon utility#143

Merged
luwes merged 3 commits intomainfrom
popover-fixes
Oct 29, 2025
Merged

feat: use popover API, add safe polygon utility#143
luwes merged 3 commits intomainfrom
popover-fixes

Conversation

@luwes
Copy link
Copy Markdown
Collaborator

@luwes luwes commented Oct 29, 2025

This pull request refactors the tooltip and popover components to improve pointer event handling, update the popover markup for better accessibility and maintainability, and enhance DOM utility functions for Shadow DOM support. The changes also include style updates and dependency additions to support these improvements.

Pointer event handling and DOM utilities:

  • Refactored MediaTooltipRoot in media-tooltip.ts to use pointer events (pointerenter, pointerleave, pointermove) instead of mouse events, ensuring better compatibility with various input devices and updating all related handler methods and position calculations to use #pointerPosition instead of #mousePosition. [1] [2] [3]
  • Added new DOM utility functions in element.ts for Shadow DOM support, including getDocumentOrShadowRoot, isElement, contains, getTarget, isShadowRoot, and helpers for working with floating nodes.
  • Exported the new safe-polygon module from dom/index.ts to make polygon-based pointer event handling available throughout the codebase.

Popover markup and accessibility:

  • Updated popover markup in both frosted/index.ts and minimal/index.ts to use the native popover attribute and popovertarget for accessibility, simplifying the structure and removing unnecessary wrapper elements. [1] [2]

Styling improvements:

  • Changed CSS selectors from media-popover-popup to media-popover and updated styles to remove margin, border, box-shadow, and background, making popovers visually cleaner and more consistent. [1] [2]

Dependency updates:

  • Added @floating-ui/core as a new dependency in package.json and pnpm-lock.yaml to support advanced floating UI positioning logic. [1] [2]

@luwes luwes requested a review from Copilot October 29, 2025 02:18
@luwes luwes self-assigned this Oct 29, 2025
@vercel
Copy link
Copy Markdown

vercel bot commented Oct 29, 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 Oct 29, 2025 2:28am
vjs-10-demo-react Ready Ready Preview Comment Oct 29, 2025 2:28am
vjs-10-website Ready Ready Preview Comment Oct 29, 2025 2:28am

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 pull request refactors tooltip and popover components to improve pointer event handling, updates popover markup to use native HTML popover API for better accessibility, and adds a safe polygon utility for enhanced pointer event management. The changes modernize the codebase with better device compatibility and simplified DOM structure.

  • Migrated from mouse events to pointer events for better multi-device support
  • Simplified popover markup using native popover attribute and popovertarget
  • Added safe polygon utility for sophisticated hover behavior management

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/utils/src/dom/safe-polygon.ts New safe polygon utility for managing pointer events within defined geometric areas
packages/utils/src/dom/index.ts Exports the new safe-polygon module
packages/utils/src/dom/element.ts Enhanced DOM utilities with Shadow DOM support and floating node helpers
packages/html/src/skins/minimal/styles.css Updated CSS selectors from media-popover-popup to media-popover with cleaner styling
packages/html/src/skins/minimal/index.ts Refactored popover markup to use native popover API
packages/html/src/skins/frosted/styles.css Updated CSS selectors matching the minimal skin changes
packages/html/src/skins/frosted/index.ts Refactored popover markup to use native popover API
packages/html/src/components/media-tooltip.ts Migrated from mouse events to pointer events with hover detection
packages/html/src/components/media-popover.ts Complete rewrite using native popover API and safe polygon utility
packages/html/package.json Added @floating-ui/core dependency
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/html/src/skins/frosted/index.ts Outdated
Comment on lines +64 to +65
// @ts-expect-error - next.host is not defined in the type
next = next.parentNode || next.host;
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

The TypeScript error suppression comment indicates a type safety issue. Consider using proper type guards or casting to handle the host property safely instead of suppressing the error.

Suggested change
// @ts-expect-error - next.host is not defined in the type
next = next.parentNode || next.host;
// Use type guard to safely access next.host if next is a ShadowRoot
next = next.parentNode || (isShadowRoot(next) ? next.host : null);

Copilot uses AI. Check for mistakes.
return typeof window !== 'undefined';
}

export function getWindow(node: any): typeof window {
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

The node parameter uses any type which reduces type safety. Consider using a more specific type like Node | Element | null to improve type checking.

Suggested change
export function getWindow(node: any): typeof window {
export function getWindow(node: Node | Element | null): typeof window {

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@vercel vercel bot temporarily deployed to Preview – vjs-10-demo-react October 29, 2025 02:28 Inactive
@vercel vercel bot temporarily deployed to Preview – vjs-10-demo-html October 29, 2025 02:28 Inactive
@vercel vercel bot temporarily deployed to Preview – vjs-10-website October 29, 2025 02:28 Inactive
@luwes luwes merged commit 419911f into main Oct 29, 2025
6 checks passed
@luwes luwes deleted the popover-fixes branch October 29, 2025 02:32
@github-actions github-actions bot mentioned this pull request Oct 28, 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