Skip to content

[color-swatch] Fix popover centering in Firefox (regression)#235

Open
DmitrySharabin wants to merge 1 commit into
mainfrom
color-swatch-anchor-fix
Open

[color-swatch] Fix popover centering in Firefox (regression)#235
DmitrySharabin wants to merge 1 commit into
mainfrom
color-swatch-anchor-fix

Conversation

@DmitrySharabin

@DmitrySharabin DmitrySharabin commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

  • Use anchor() functions (bottom: anchor(top), left: anchor(center)) instead of position-area: top for popover positioning
  • Firefox does not center the popover with position-area when the anchor is inside a chart's complex layout context (e.g. contain: size, absolute positioning)

Known issue: Firefox still clips anchor-positioned top-layer elements by ancestor overflow: hidden — a browser bug with no CSS-only workaround. No existing Bugzilla report found; needs to be filed.

Test plan

  • Hover compact swatches — tooltip centered above swatch (Chrome, Firefox, Safari)
  • Hover chart swatches — tooltip centered (Chrome ✓, Firefox: centered but clipped by chart overflow)
  • flip-block still works when swatch is near viewport top edge

🤖 Generated with Claude Code

@netlify

netlify Bot commented Jun 5, 2026

Copy link
Copy Markdown

Deploy Preview for color-elements ready!

Name Link
🔨 Latest commit a20b5fa
🔍 Latest deploy log https://app.netlify.com/projects/color-elements/deploys/6a245294d7c2440008e51a2b
😎 Deploy Preview https://deploy-preview-235--color-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@DmitrySharabin DmitrySharabin changed the title [color-swatch] Fix popover centering in Firefox [color-swatch] Fix popover centering in Firefox (regression) Jun 5, 2026
@DmitrySharabin DmitrySharabin requested a review from LeaVerou June 5, 2026 13:46
Comment thread src/color-swatch/color-swatch.css Outdated
bottom: anchor(top);
left: anchor(center);
translate: -50% 0;
margin-bottom: calc(var(--_pointer-height) * 0.8);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
margin-bottom: calc(var(--_pointer-height) * 0.8);
margin-block-end: calc(var(--_pointer-height) * 0.8);

@DmitrySharabin DmitrySharabin Jun 5, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I excluded the change from the PR. It wasn't necessary. Simply margin was OK.

@DmitrySharabin DmitrySharabin force-pushed the color-swatch-anchor-fix branch from f4f37b3 to 0a7b61a Compare June 5, 2026 13:53
Use anchor() functions instead of position-area: top for popover
positioning. Firefox does not center the popover with position-area
when the anchor is inside a chart's complex layout context.

Note: Firefox still clips anchor-positioned top-layer elements by
ancestor overflow:hidden — a browser bug with no known workaround.
No existing Bugzilla report found; needs to be filed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@DmitrySharabin DmitrySharabin force-pushed the color-swatch-anchor-fix branch from 0a7b61a to a20b5fa Compare June 6, 2026 17:02
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