Skip to content

[popups] Snap --anchor-width/height to device pixel grid - #4082

Merged
flaviendelangle merged 3 commits into
mui:masterfrom
flaviendelangle:popup-decimal-placement
Feb 13, 2026
Merged

flaviendelangle merged 3 commits into
mui:masterfrom
flaviendelangle:popup-decimal-placement

Conversation

@flaviendelangle

@flaviendelangle flaviendelangle commented Feb 13, 2026 •

Copy link
Copy Markdown
Member

Closes #4061

The issue was the small black rectangle that flickers at the top right of the floating container.

Before

Screencast.2026-02-13.09.54.01.mp4

After

Screencast.2026-02-13.09.54.18.mp4

@flaviendelangle flaviendelangle self-assigned this Feb 13, 2026
@flaviendelangle flaviendelangle added type: bug It doesn't behave as expected. component: combobox Changes related to the combobox component. labels Feb 13, 2026
@pkg-pr-new

pkg-pr-new Bot commented Feb 13, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/@base-ui/react@4082
    
    pnpm add https://pkg.pr.new/@base-ui/utils@4082
    

commit: 36b1150

@mui-bot

mui-bot commented Feb 13, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+153B(+0.03%) 🔺+79B(+0.05%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Feb 13, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 36b1150
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/698f05127ab689000825c981
😎 Deploy Preview https://deploy-preview-4082--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@flaviendelangle
flaviendelangle marked this pull request as ready for review February 13, 2026 08:56
@greptile-apps

greptile-apps Bot commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

Fixed a visual bug where a small black rectangle would flicker at the top right of the floating container when the anchor element had fractional pixel dimensions. The fix snaps anchor dimensions to device pixels before setting CSS custom properties (--anchor-width and --anchor-height), ensuring the popup's visual width matches the anchor's exactly.

The implementation correctly handles device pixel ratio by:

  • Multiplying bounding rect coordinates by DPR
  • Rounding to nearest device pixel
  • Calculating width/height in device pixels
  • Converting back to CSS pixels

This prevents sub-pixel rendering artifacts that occurred when the anchor element's dimensions were between physical pixels.

Confidence Score: 5/5

  • This PR is safe to merge with no concerns
  • The fix is well-targeted and addresses a specific rendering issue with fractional pixels. The mathematical approach is sound (DPR multiplication → rounding → division), and the change is isolated to the size middleware's apply function. The fix follows best practices by using window.devicePixelRatio || 1 as a fallback.
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/utils/useAnchorPositioning.ts Fixed fractional pixel rendering issue by snapping anchor dimensions to device pixels in the size middleware

Last reviewed commit: a734ee2

@atomiks atomiks changed the title [Combobox] Fix popup placement with fractional pixels [popups] Snap --anchor-width/height to device pixel grid Feb 13, 2026
@atomiks atomiks added scope: all components Widespread work has an impact on almost all components. and removed component: combobox Changes related to the combobox component. labels Feb 13, 2026
@flaviendelangle
flaviendelangle merged commit ac16cf9 into mui:master Feb 13, 2026
7 checks passed
@flaviendelangle
flaviendelangle deleted the popup-decimal-placement branch February 13, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: all components Widespread work has an impact on almost all components. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[combobox] Input and popup elements width mismatch when inheriting width with decimal places

3 participants