Skip to content

fix(core): cap the Selector family's trigger-width list minimum at the viewport - #12274

Closed
josephfarina wants to merge 2 commits into
mainfrom
rl-19-selector-viewport-cap
Closed

josephfarina wants to merge 2 commits into
mainfrom
rl-19-selector-viewport-cap

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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

  1. Why does it happen? The list layer sets min-width: anchor-size(width). A CSS minimum beats a maximum, so the runtime's max-inline-size cap does not apply to it.
  2. Why does it hurt? A layer wider than the cap fits no position-try option, including the slide options that exist to bring a wide layer back on screen. The browser keeps the base option.
  3. Why does it matter? Users cannot read or reach options that sit past the screen edge.

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 or menuWidth) 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 popover style in each of the three components changes from anchor-size(width) to min(anchor-size(width), <viewport cap>). It uses the same firstThatWorks chain as DropdownMenu. No API, default, or visual change for a trigger narrower than the cap.

Evidence

  • Reproduction before the change: a 390 px phone with a trigger 358.6 px wide. The layer's computed min-width was 358.6 px and its max-inline-size was 358 px. The minimum won, so no position option fit.
  • Result after the change: the minimum resolves to the 358 px cap, so the layer is no wider than the cap and lands on its preferred, start-aligned position.
  • Representative unchanged path: a trigger narrower than the cap keeps a list at least as wide as the trigger (min() picks the trigger width).
  • Regression test: Selector.viewportCap.test.tsx, MultiSelector.viewportCap.test.tsx, and ComplexSelector.viewportCap.test.tsx assert the clamped minimum on the list layer. All three fail without the change and pass with it.

Scope

Components: Selector, MultiSelector, ComplexSelector

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • vitest run --project ui packages/core/src/Selector packages/core/src/MultiSelector packages/core/src/ComplexSelector: 26 files, 740 tests pass.
  • With the source change reverted, the three new tests fail.
  • Real Chromium at 390 px: computed min-width and max-inline-size read on the open list layer.

@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 17, 2026 9:58am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 17, 2026
@astracat-bot

astracat-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 17, 2026, 10:10 AM UTC

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 369edae

Storybook · Sandbox · built from this PR's head

Current run: The current CI run concluded cancelled. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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).

Automated review (maintainer link)

Comment thread packages/core/src/Selector/Selector.tsx Resolved

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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's max-inline-size cap. 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 firstThatWorks chain. 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 declares min-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.
  • 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).

Automated review (maintainer link)

@josephfarina josephfarina reopened this Nov 17, 2026
josephfarina added a commit that referenced this pull request Nov 18, 2026
josephfarina added a commit that referenced this pull request Nov 19, 2026
josephfarina added a commit that referenced this pull request Nov 19, 2026
josephfarina added a commit that referenced this pull request Nov 19, 2026
- #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]>
@josephfarina

Copy link
Copy Markdown
Contributor Author

Landed in #12713.

@github-actions
github-actions Bot deleted the rl-19-selector-viewport-cap branch November 19, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — 369edae9 Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant