[popups] Fix transform origin for start/end alignment#5015
Open
atomiks wants to merge 6 commits into
Open
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,186.40 ms +138.58 ms(+13.2%) | Renders: 50 (+0) | Paint: 1,794.69 ms +208.97 ms(+13.2%)
8 tests within noise — details 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. |
37bdeb3 to
cf30a2a
Compare
cf30a2a to
01641f2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before: https://base-ui.com/react/components/combobox#input-inside-popup
After: https://deploy-preview-5015--base-ui.netlify.app/react/components/combobox#input-inside-popup
The
transformOriginmiddleware inuseAnchorPositioningalways derived the cross-axis origin from thearrowmiddleware data. Without an arrow element, a zero-size virtual arrow is used, which the arrow middleware centers against the anchor. That's correct forcenteralignment (the origin tracks the anchor's center even when the popup shifts), but forstart/endthe popup's edge is aligned with the anchor's edge, so the scale animation emanated from the anchor's center partway into the popup — and for an anchor wider than the popup, from a clamped point near the popup's far edge.The cross-axis origin is now picked explicitly:
centeralign → anchor's center via the virtual arrow (unchanged).start/endalign → the popup's aligned edge:0%/100%. Uses the rendered alignment and Floating UI's RTL platform info, so it stays correct after alignment flips and in RTL.start/endalign → anchor's center via the virtual arrow, since the popup edge no longer lines up with the anchor edge.The middleware is also simplified: instead of a four-entry side map plus a separate overlap string, it computes one cross-axis and one side-axis coordinate (the anchor-overlap case for context menus is folded into the side coordinate) and joins them in axis order.
Added Chromium tests asserting the exact
--transform-originvalue for center/start/end alignment, RTL start/end alignment, shifted start alignment, horizontal sides,sideOffset, and the arrow-present case.