Repository navigation
fix(core): cap the Selector family's trigger-width list minimum at the viewport - #12274
josephfarina wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Requesting changes for two wording fixes. The clamp itself is right.
The change brings Selector, MultiSelector and ComplexSelector in line with the layer viewport-inset rule, the same way DropdownMenu and Popover already do: a component's trigger-width minimum is clamped by the runtime's viewport cap. The new tests fail without the change and pass with it. CI's test and build jobs did not run on this head because CI was full, so they need a re-run before merge.
Blocking
- The changeset says a trigger wider than the viewport no longer pushes the option list off screen, but on this branch a 406 px trigger that starts 8 px before the left edge of a 390 px screen still opens the list at x = −8 px. Please reword it to the case the change fixes, for example "the option list's trigger-width minimum is now clamped by the layer's viewport cap, so a trigger wider than that cap no longer makes the list wider than the cap."
- The description says the clamped layer fits the slide option, but on this branch it lands on its preferred, start-aligned position (at the trigger's edge), so please correct that sentence.
Non-blocking
- The new source comment in the three components restates the declaration and puts two topics in one passive sentence. Consider: "Clamp the trigger width with the viewport cap. A CSS minimum otherwise wins over the layer's maximum."
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claims
- Changeset: a trigger wider than the viewport no longer pushes the list off screen. False: a 406 px trigger starting 8 px left of a 390 px screen still opens the list at x = −8 px in all three components.
- Changeset: the list's trigger-width minimum is capped at the viewport. Verified in substance: it is capped at the viewport minus the layer gutters (
Selector.tsx:450-454,MultiSelector.tsx:377-381,ComplexSelector.tsx:250-254). - Description: a trigger about as wide as the screen can open the list partly off screen. Verified: on the base, a 406 px trigger's list runs past both edges, and a 374 px trigger's list sits flush at the screen edge.
- Description: the trigger-width minimum beats the runtime's inline-size cap, so no position fits. Verified: the base computes min-width 374/406 px against a max-inline-size of 358 px.
- Description: the fix clamps the minimum exactly as DropdownMenu and Popover do. Verified (
DropdownMenu.tsx:247-253,Popover.tsx:464-469). - Description: the layer runtime's viewport-inset rule requires the clamp. Verified (
docs/architecture/layer-runtime.md, Viewport inset and INV11). - Description: after the change the minimum resolves to the 358 px cap. Verified in Chromium at 390 px.
- Description: the layer then fits the slide option. False: it lands on its preferred, start-aligned position.
- Description: nothing changes in API, defaults or visuals for a trigger narrower than the cap. Verified: the API generator lists 0 rows, and
min()keeps the trigger width. - Description: the three new tests fail without the change and pass with it. Verified.
- Description: the three component suites pass (26 files, 740 tests). Verified.
- Description: one defect is restored, with no hidden API, default or interaction change and no internal context in public text. Verified.
- Files
.changeset/selector-list-viewport-cap.md: finding (overstated claim).packages/core/src/Selector/Selector.tsx: clear (non-blocking comment wording).packages/core/src/MultiSelector/MultiSelector.tsx: clear (same clamp and comment as Selector).packages/core/src/ComplexSelector/ComplexSelector.tsx: clear (same clamp and comment as Selector).packages/core/src/Selector/Selector.viewportCap.test.tsx: clear.packages/core/src/MultiSelector/MultiSelector.viewportCap.test.tsx: clear.packages/core/src/ComplexSelector/ComplexSelector.viewportCap.test.tsx: clear (all three tests expect the same declaration Popover's test already pins).
There was a problem hiding this comment.
Approved pending CI: the CI run on this head was cancelled because CI was full, so its build and test jobs need a re-run before merge.
Both earlier findings are fixed: the changeset now describes exactly the clamp this change makes, and the description now says the clamped list lands on its preferred, start-aligned position. The clamp brings Selector, MultiSelector and ComplexSelector in line with the layer viewport-inset rule, as DropdownMenu, Popover and BaseTypeahead already are, and the new tests fail without it and pass with it.
Claims and files checked
Review mode: incremental; reason: none
- changed rules (0): none
- Claims
- Changeset: the list's trigger-width minimum is clamped by the layer's viewport cap, so a trigger wider than the cap no longer makes the list wider than the cap. Verified: on a 390 px screen the list is 358 px wide, the cap, for 374 px and 358.6 px triggers (
Selector.tsx:449-455,MultiSelector.tsx:376-382,ComplexSelector.tsx:249-255). - Title: the Selector family's trigger-width list minimum is capped at the viewport. Verified in substance: it is capped at the viewport minus the layer gutters.
- Description: a trigger about as wide as the screen can open the list partly off screen, out of reach. Verified: on the base a 406 px trigger's list runs past both edges of a 390 px screen, and a 374 px trigger's list moves to the screen edge, off the trigger.
- Description: the list's
anchor-size(width)minimum beats the runtime'smax-inline-sizecap. Verified: on the base the layer computes a 374px minimum against a 358px cap. - Description: a layer wider than the cap fits no position option, and the browser keeps the base option. Verified for a 374 px trigger at x = 8: the base layer keeps the preferred option's margins and is shifted to x = 0.
- Description: the fix clamps the minimum exactly as DropdownMenu and Popover do, with the same
firstThatWorkschain. Verified (DropdownMenu.tsx:247-253,Popover.tsx:464-470). - Description: a trigger that itself runs past the screen edge is not covered. Verified: such a trigger's list still starts past that edge on this branch.
- Description: the layer runtime's viewport-inset rule requires a consumer to clamp its own minimum, and these three components did not. Verified (
docs/architecture/layer-runtime.md, Viewport inset and INV11; the base declaresmin-width: anchor-size(width)). - Description: no API, default or visual change for a trigger narrower than the cap. Verified: the API generator lists 0 rows, and a 300 px trigger renders a pixel-identical frame.
- Description: a 358.6 px trigger on a 390 px phone gives the layer a 358.6 px minimum against a 358 px cap. Verified: the base computes 358.594px against 358px.
- Description: after the change the minimum resolves to the 358 px cap and the list lands on its preferred, start-aligned position. Verified: the head list is 358 px wide at the trigger's start, with the gutter on the far edge.
- Description: a trigger narrower than the cap keeps a list at least as wide as the trigger. Verified: 300 px list for a 300 px trigger on base and head.
- Description: the three new tests assert the clamped minimum, fail without the change and pass with it. Verified.
- Description: the three component suites pass (26 files, 740 tests). Verified.
- Description: the open layer's minimum and cap were read in real Chromium at 390 px. Verified by an independent Chromium probe at 390 px.
- Description: one defect is restored, with no hidden API, default or interaction change and no internal context in public text. Verified.
- Changeset: the list's trigger-width minimum is clamped by the layer's viewport cap, so a trigger wider than the cap no longer makes the list wider than the cap. Verified: on a 390 px screen the list is 358 px wide, the cap, for 374 px and 358.6 px triggers (
- Files
.changeset/selector-list-viewport-cap.md: clear (the earlier overstatement is fixed).packages/core/src/Selector/Selector.tsx: clear.packages/core/src/MultiSelector/MultiSelector.tsx: clear (same clamp and comment as Selector).packages/core/src/ComplexSelector/ComplexSelector.tsx: clear (same clamp and comment as Selector).packages/core/src/Selector/Selector.viewportCap.test.tsx: clear.packages/core/src/MultiSelector/MultiSelector.viewportCap.test.tsx: clear.packages/core/src/ComplexSelector/ComplexSelector.viewportCap.test.tsx: clear (all three expect the declaration DropdownMenu's and Popover's tests already pin).
- #12072 fix(templates): payment form and checkout wrap the summary below the form on a narrow first paint Author: Joey Farina <[email protected]> - #12274 fix(core): cap the Selector family's trigger-width list minimum at the viewport Author: josephfarina <[email protected]> - #12215 fix(cli): advise keeping one dependency when two packages declare one provider ID Author: Joey <[email protected]> - #12322 [experimental] export --reverse: use the project's own copy of an aliased file, or restore the page's copy with its paths entry Author: josephfarina <[email protected]> - #12403 docs(core): Text's as and PowerSearch's statusVariant list every value their types allow Author: Joey Farina <[email protected]> - #12494 fix(templates): dashboard templates use page sections, not cards, for page regions Author: Joey Farina <[email protected]> - #12282 fix(cli): theme build --check and doctor ignore which CLI release, and which command name, built a theme Author: Joey Farina <[email protected]> - #12420 fix(Chat): ChatToolCalls and ChatDictationButton without a required prop name it and the fix in development Author: Joey Farina <[email protected]> - #12205 fix(cli): equally scored icons put first one whose id the query names in full Author: Joey Farina <[email protected]> - #12455 fix(core): a theme sets the room between a checkbox or a switch and its label Author: josephfarina <[email protected]> - #12658 perf(cli): the first theme build after a CLI upgrade reuses the JavaScript it compiled from a theme's local modules Author: Joey <[email protected]> - #12323 [experimental] export: React logs no render timings while the export draws a page Author: Joey Farina <[email protected]>
|
Landed in #12713. |
User impact
On a phone, a Selector, MultiSelector, or ComplexSelector whose trigger is about as wide as the screen can open its option list partly off screen. The list's minimum width is the trigger's width, and nothing caps that minimum, so the list can be wider than the layer runtime's viewport cap. Once it is wider than the cap, no position option fits, and the browser falls back to the preferred position, which can run past the screen edge.
Problem and solution fit
min-width: anchor-size(width). A CSS minimum beats a maximum, so the runtime'smax-inline-sizecap does not apply to it.The fix clamps the minimum with the runtime's cap expression, exactly as DropdownMenu and Popover already do. A trigger that itself runs past the screen edge is a separate layer-runtime case and is not covered here.
Expected behavior and authority
architecture:layer-runtime(Viewport inset): "A consumer caps its painted surface with the same definition and clamps any minimum of its own (trigger matching, an explicit width ormenuWidth) with the runtime's cap expression, because a CSS minimum otherwise wins over a maximum." DropdownMenu (popoverMatchTrigger) and Popover (matchTrigger) follow this rule. These three components did not.Smallest restoration
The
popoverstyle in each of the three components changes fromanchor-size(width)tomin(anchor-size(width), <viewport cap>). It uses the samefirstThatWorkschain as DropdownMenu. No API, default, or visual change for a trigger narrower than the cap.Evidence
min-widthwas 358.6 px and itsmax-inline-sizewas 358 px. The minimum won, so no position option fit.min()picks the trigger width).Selector.viewportCap.test.tsx,MultiSelector.viewportCap.test.tsx, andComplexSelector.viewportCap.test.tsxassert the clamped minimum on the list layer. All three fail without the change and pass with it.Scope
Components: Selector, MultiSelector, ComplexSelector
Testing
vitest run --project ui packages/core/src/Selector packages/core/src/MultiSelector packages/core/src/ComplexSelector: 26 files, 740 tests pass.min-widthandmax-inline-sizeread on the open list layer.