Skip to content

refactor: migrate tooltip and popover to CSS Anchor Positioning#5990

Draft
Copilot wants to merge 7 commits intomainfrom
copilot/migrate-tooltip-popover-css
Draft

refactor: migrate tooltip and popover to CSS Anchor Positioning#5990
Copilot wants to merge 7 commits intomainfrom
copilot/migrate-tooltip-popover-css

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

Migrates tooltip and popover positioning from JavaScript to CSS Anchor Positioning for modern browsers, with JavaScript fallback for older browser compatibility.

CSS Changes

  • _popover-component.scss: Added @supports (anchor-name: --db-popover-anchor) block with:

    • position-anchor and position-area for all placement variants
    • position-try-fallbacks with flip-block, flip-inline for automatic collision detection
    • Extracted fallback strategies into reusable SCSS variables
  • tooltip.scss: Added anchor-name on [data-has-tooltip="true"] parent

  • popover.scss: Added anchor-name on .db-popover container

JavaScript Feature Detection

  • floating-components.ts:
    • Added exported supportsCSSAnchorPositioning() for consumers to detect support
    • handleFixedPopover() and handleFixedDropdown() skip JS positioning when CSS handles it
export const supportsCSSAnchorPositioning = (): boolean => {
  if (typeof window === 'undefined' || typeof CSS === 'undefined') {
    return false;
  }
  return CSS.supports('anchor-name', '--db-popover-anchor');
};

Browser Support

  • Chrome 125+, Edge 125+: CSS Anchor Positioning with automatic viewport collision detection
  • Older browsers: Existing JavaScript positioning (unchanged)
Original prompt

For tooltip and popover we're using JavaScript to both positon as well as collision detect (viewport edges) and reposition the elements. Please migrate those to CSS Anchor Positioning (but leave the existing JavaScript for older browser compatibility), as well as add some feature detection to the existing JavaScript code.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

🔭🐙🐈 Test this branch here: https://design-system.deutschebahn.com/core-web/review/copilot/migrate-tooltip-popover-css

@changeset-bot
Copy link

changeset-bot bot commented Feb 5, 2026

⚠️ No Changeset found

Latest commit: d77c38b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot Agent and others added 2 commits February 5, 2026 13:08
… detection

Co-authored-by: mfranzke <787658+mfranzke@users.noreply.github.com>
Co-authored-by: mfranzke <787658+mfranzke@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate tooltip and popover positioning to CSS Anchor Positioning feat: migrate tooltip and popover to CSS Anchor Positioning Feb 5, 2026
Copilot AI requested a review from mfranzke February 5, 2026 13:17
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Collaborator

Choose a reason for hiding this comment

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

The placement isn't working. Always opens to the bottom.

Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a gap between the button and the tooltip, and it isn't centered anymore

Copy link
Collaborator

Choose a reason for hiding this comment

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

take no prisoners development.

@mfranzke mfranzke changed the title feat: migrate tooltip and popover to CSS Anchor Positioning refactor: migrate tooltip and popover to CSS Anchor Positioning Feb 5, 2026
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

3 participants