Repository navigation
[select] Fix alignItemWithTrigger fallback with browser zoom - #4292
Conversation
commit: |
Bundle size report
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codex ReviewOverviewThis 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/5High confidence after reviewing the full Notes
|
f6c7a60 to
a4ce4da
Compare
| 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 }; | ||
| } |
There was a problem hiding this comment.
This returns 1 instead of 0 in unsafe cases so there are no divide-by-zero issues 😅
|
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 |
9d4e290 to
086ee08
Compare
086ee08 to
543cb35
Compare
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.PositionerwithalignItemWithTriggercould 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
Verification
Verified on
localhost:3007/react/components/selectwith synthetic page zoom (document.documentElement.style.zoom = '0.9'):data-side="bottom").data-side="none").