Skip to content

[select] Fix alignItemWithTrigger fallback with browser zoom - #4292

Merged
atomiks merged 3 commits into
mui:masterfrom
atomiks:codex/select-4290-zoom-positioning
Mar 11, 2026
Merged

atomiks merged 3 commits into
mui:masterfrom
atomiks:codex/select-4290-zoom-positioning

Conversation

@atomiks

@atomiks atomiks commented Mar 10, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4290

Screen.Recording.2026-03-10.at.4.33.17.pm.mov

CSS zoom looks to correctly replicate the rounding issues and I manually verified above in the recording

Summary

Select.Positioner with alignItemWithTrigger could intermittently fall back to standard positioning at non-100% browser zoom.

The issue came from mixing zoom-scaled getBoundingClientRect() values with layout-pixel measurements used during the initial popup placement logic. For short popups, that mismatch could make the computed aligned height land just below the fallback threshold, so the popup would sometimes open below the trigger instead of staying aligned with it.

This showed up more easily in smaller selects like the docs styling selector, while larger demos were less likely to hit the same rounding edge case.

Changes

  • Normalize popup placement rects using Floating UI's scale calculation before comparing them with layout-pixel measurements.
  • Allow a 1px tolerance in the fallback height comparison to avoid flipping due to subpixel rounding.
  • Add a regression test covering zoom-scaled DOMRect values for a short popup.

Verification

Verified on localhost:3007/react/components/select with synthetic page zoom (document.documentElement.style.zoom = '0.9'):

  • Before this change, the docs styling selector fell back to standard positioning (data-side="bottom").
  • After this change, it consistently stays in aligned mode (data-side="none").
  • The larger select demo continues to behave correctly.

@atomiks atomiks added component: select Changes related to the select component. type: bug It doesn't behave as expected. labels Mar 10, 2026
@pkg-pr-new

pkg-pr-new Bot commented Mar 10, 2026 •

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

  • vite-css-base-ui-example

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

commit: c73a654

@mui-bot

mui-bot commented Mar 10, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+127B(+0.03%) 🔺+99B(+0.07%)

Details of bundle changes


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

@netlify

netlify Bot commented Mar 10, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 7c1069a
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69b0afd8cc378d0008d885f6
😎 Deploy Preview https://deploy-preview-4292--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.

@atomiks

atomiks commented Mar 10, 2026 •

Copy link
Copy Markdown
Contributor Author

Codex Review

Overview

This patch fixes the Select popup zoom bug by keeping the placement math in the same coordinate space and by tolerating the small rounding errors that appear in the short-popup path. It also adds browser regressions for the two edge cases that were still causing the popup to fall back or grow too tall at non-100% zoom.

Findings (None)

No blocking issues found in this patch.

Confidence: 4/5

High confidence after reviewing the full upstream/master...HEAD diff for the changed Select popup files and verifying the updated regression coverage. The remaining uncertainty is mostly browser-specific layout behavior, but the new Chromium regressions now cover both the 1px maxScrollTop drift and the fractional-height threshold case that were missing earlier.

Notes

  • Reviewed against upstream/master...543cb35a0.
  • Verified with pnpm test:jsdom SelectPopup --no-watch, pnpm test:chromium SelectPopup --no-watch, and pnpm typescript.

@atomiks
atomiks force-pushed the codex/select-4290-zoom-positioning branch from f6c7a60 to a4ce4da Compare March 10, 2026 05:31
Comment on lines +586 to +589
function getScale(element: HTMLElement) {
// The platform API is async-capable, but the DOM platform returns a plain scale object.
return floatingPlatform.getScale(element) as { x: number; y: number };
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This returns 1 instead of 0 in unsafe cases so there are no divide-by-zero issues 😅

@atomiks
atomiks marked this pull request as ready for review March 10, 2026 05:35
@michaldudak

Copy link
Copy Markdown
Member

It seems to fix the issue on Chrome/Edge on both Windows and macOS, but I still see the problem on Safari (both on macOS and iPad when using a mouse or pen).

Screen.Recording.2026-03-10.at.09.38.35.mov

@atomiks
atomiks force-pushed the codex/select-4290-zoom-positioning branch 2 times, most recently from 9d4e290 to 086ee08 Compare March 10, 2026 11:31
@atomiks
atomiks force-pushed the codex/select-4290-zoom-positioning branch from 086ee08 to 543cb35 Compare March 10, 2026 11:38
@atomiks
atomiks merged commit 7ac3f10 into mui:master Mar 11, 2026
6 checks passed
@atomiks
atomiks deleted the codex/select-4290-zoom-positioning branch March 11, 2026 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: select Changes related to the select component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[select] alignItemWithTrigger positioning breaks at non-100% browser zoom

3 participants