Skip to content

fix(Selector): shrink a flipped list to the room above the software keyboard - #11749

Open
Geervan wants to merge 3 commits into
meta:mainfrom
Geervan:fix/flipped-selector-keyboard-cap
Open

Geervan wants to merge 3 commits into
meta:mainfrom
Geervan:fix/flipped-selector-keyboard-cap

Conversation

@Geervan

@Geervan Geervan commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #11725

Fixes software keyboard occlusion on a Selector list flipped above its trigger (e.g. in landscape mode) when the virtual keyboard is visible.

Root Cause

  • Generic Layer Cap Preservation: By design (spec:AST-059 FR9 & architecture:layer-runtime INV11), generic anchored layers placed above their trigger are not capped by useLayerKeyboardClearance so that popovers and menus do not shrink while their bottom stays under the keyboard. Consequently, a flipped Selector list remained at its natural height (200 px when an option grows on main).
  • Premature Margin Clamp: In useSelectedItemOverlayMargin (packages/core/src/Selector/hooks.ts), aboveAnchor was clamped using min(${anchorTop - listboxHeight - gutter}px, ...), which baked in the unshrunk measured height (200 px). When the keyboard rose, this clamp prevented the list from lifting above the keyboard line, leaving the bottom of the 200 px list at 216 px (36 px past the 180 px keyboard line).

Solution

  • Shrink Only Selector's Flipped List: In packages/core/src/Selector/hooks.ts and packages/core/src/Selector/Selector.tsx, once a margin has been set and the list is flipped while open (hadMargin && isFlippedWhileOpen), useSelectedItemOverlayMargin returns maxHeight constrained to the room between the top viewport gutter and the keyboard line (min(300px, calc(${viewport}px - var(${LAYER_KEYBOARD_INSET_PROPERTY}, ${gutter}px) - ${gutter}px))) — falling back to ${gutter}px with no keyboard up so both viewport gutters hold — and composes it into the listbox's style, resetting to undefined on close or uncap. Deferring this cap until a margin is set preserves the Layer runtime's keyboard cap when a tall list opens with the keyboard already up, and omitting the duplicate LAYER_KEYBOARD_CLEARANCE_PX subtraction (already included in --_layer-keyboard-inset-block-end) lets the flipped list fill the full 164 px room (16–180 px).
  • Unclamped Keyboard Lift: In packages/core/src/Selector/hooks.ts, relaxed aboveAnchor to max(${flipped}px, calc(${keyboardEnd}px + var(${LAYER_KEYBOARD_INSET_PROPERTY}, 0px))), allowing the list to lift all the way to the keyboard line (180 px) with its top resting at the 16 px top gutter.
  • Unmodified Layer Modules: No changes under packages/core/src/Layer/ (0 diff lines against main).
  • Chromium Tests & Changeset: Added contract tests in packages/core/src/Selector/__tests__/SelectorKeyboardInset.a11y.chromium.spec.ts covering flipping, keyboard raising (asserting top within 0.5 px of the 16 px gutter and bottom <= 180.5 px), scrolling, option activation, clean reset to natural height (verifying both listbox.style.maxHeight === '' and computed --_layer-keyboard-max-block-size === '100vh'), and keeping a flipped list within both gutters in a short viewport with no keyboard; added a patch changeset.

Verification

  • Unit (Selector): vitest run --project ui packages/core/src/Selector/Selector.test.tsx --maxWorkers=1 — 265 passed
  • Unit (useLayerKeyboardClearance): vitest run --project ui packages/core/src/Layer/useLayerKeyboardClearance.test.tsx --maxWorkers=1 — 34 passed
  • Browser (SelectorKeyboardInset): playwright test SelectorKeyboardInset.a11y.chromium.spec.ts --config playwright.config.ts --project=chromium — 20 passed
  • Typecheck: tsc -p packages/core --noEmit — clean (0 errors)
  • Pre-commit: eslint (0 errors, 0 warnings), prettier, check:sync, check:knowledge, check:changesets — clean

@vercel

vercel Bot commented Nov 14, 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 25, 2026 6:11pm UTC

Request Review

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Nov 14, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 14, 2026
@astracat-bot

astracat-bot Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Nov 27, 2026, 12:05 PM UTC

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 8cccf63

This branch's preview address cannot be known in advance; open it from Vercel's comment.

Current run: The current CI run concluded failure. 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.

Changes are needed before this can land.

  • The new rule in useLayerKeyboardClearance.ts keeps the keyboard cap on every layer placed above its trigger whose top reaches the gutter, so a Popover or menu flipped above a low trigger now shrinks while its bottom stays under the keyboard, which spec:AST-059 FR9 and architecture:layer-runtime INV11 say must not happen.
  • The pull request's own Chromium case for #11725 (SelectorKeyboardInset.a11y.chromium.spec.ts:445) fails at this head: the flipped list is capped to 164 px but ends at 298 px, under the 180 px keyboard line, and its last check on the inline cap property cannot pass while useLayer writes 100vh inline.
  • StyleX does not rename the --_layer-keyboard-* properties (it keeps the declared name and passes the value through a generated variable), so the inline write in useLayer.tsx only duplicates the existing keyboardCap style and should go, together with the unused import, the cast and the new LayerTouch.ts re-exports.
  • The branch includes the commits of open #10062 at an older head, so please rebase onto main once #10062 lands, or onto its current head with a matching Stack: line in both descriptions, leaving only your Layer commit here.

Shrinking only Selector's flipped list, for example where Selector/hooks.ts builds the flipped margin from the keyboard inset, would leave other layers as they are. Because the Layer modules are shared, please also report the first-load gzip delta on the docs, form, menu and table reference pages (architecture:component-import-boundaries INV10). CI has not run on this head yet; it needs a maintainer's ci:run label.

Claims and files checked

Claims:

  • Fixes #11725, a flipped Selector list under a keyboard: false; the Chromium case for it fails (list ends at 298 px, keyboard line at 180 px).
  • The cap was dropped before layout settled: false; dropping it for a layer above its trigger is the deliberate rule (spec:AST-059 FR9).
  • StyleX mangled the custom property names: false; StyleX keeps the names, and the keyboard cap works on main.
  • The cap is kept when the layer rests at the top gutter: verified at useLayerKeyboardClearance.ts:286-292, for every anchored layer.
  • The custom properties are passed inline on the layer: verified at useLayer.tsx:2464-2478; they duplicate the StyleX style.
  • Four unit tests were added and the file's 38 tests pass: verified.
  • A Chromium test was added: verified; it fails at this head.
  • A patch changeset credits the author: verified.
  • Lint is clean: no errors; two warnings in useLayer.tsx.
  • Changeset: flipped Selector lists are capped against the keyboard line at the top gutter: false at this head, and the rule reaches every anchored layer.
  • Changeset: the selected row stays on the trigger when an option grows, the overlay measures again before paint, and no API changes: verified (the growth proofs pass in Chromium, no public API change), but this is #10062's change.

Files:

  • .changeset/flipped-selector-keyboard-cap.md: claim false at this head.
  • .changeset/selector-overlay-growth.md: belongs to #10062.
  • apps/storybook/stories/Selector.stories.tsx: from #10062; the story itself is clear.
  • packages/core/src/Layer/LayerTouch.ts: re-exports only the inline write needs.
  • packages/core/src/Layer/useLayer.tsx: duplicate inline write, unused import, cast.
  • packages/core/src/Layer/useLayerKeyboardClearance.ts: changes the rule for every layer above its trigger.
  • packages/core/src/Layer/useLayerKeyboardClearance.test.tsx: passes; no case for a plain bottom-held layer with a gutter margin.
  • packages/core/src/Selector/Selector.test.tsx: from #10062; passes.
  • packages/core/src/Selector/__tests__/SelectorFlippedOverlayKeyboard.a11y.browser.spec.ts: from #10062; passes in Chromium.
  • packages/core/src/Selector/__tests__/SelectorKeyboardInset.a11y.chromium.spec.ts: the new case fails; the others pass.
  • packages/core/src/Selector/__tests__/SelectorOverlayGrowth.a11y.browser.spec.ts: from #10062; passes in Chromium.
  • packages/core/src/Selector/hooks.ts: #10062's change at an older head.

Automated review (maintainer link)

Comment thread packages/core/src/Layer/useLayer.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.

Approval waits on an engineering owner's decision, and changes are needed whichever way it goes.

Approval needs an engineering owner to settle the governing spec for this addition: component:Selector FR2 asks the list to end above any software keyboard, while spec:AST-059 FR9 and architecture:layer-runtime INV11 leave a layer placed above its trigger as it is and keep one runtime definition of the viewport caps, so they need to decide whether a flipped list shrinks above the keyboard and whether that cap belongs to the layer runtime or may stay in Selector.

  • Selector/hooks.ts:326 writes the inline cap whenever the layer reads as flipped, including the open's first measure before the overlay margin applies, so a nine-option list opened with the keyboard already up ends at 296 px, 116 px under the keyboard line, and SelectorKeyboardInset.a11y.chromium.spec.ts:412 fails (it passes on #10062's head); writing the cap only once the flipped margin is set fixes it, and composing the cap into the dropdown's StyleX max-height would keep the runtime's keyboard cap in play.
  • Selector/hooks.ts:328 subtracts the 10 px clearance from --_layer-keyboard-inset-block-end, which already includes it, so the flipped list is 154 px at 26–180 px instead of filling the 164 px room from the 16 px gutter; dropping that term gives 16–180 px.
  • The title "fix(core): preserve keyboard clearance cap for flipped layers" describes a layer runtime change, but no Layer module changes and only Selector's flipped list is capped, so please retitle it, for example fix(Selector): shrink a flipped list to the room above the software keyboard.
  • The branch carries all of #10062 (13 of its 14 commits, including #10062's changeset) while the Stack: lines name #11725 as this pull request and #10062's description has none, so please use Stack: #10062 → #11749 in both descriptions or rebase onto main once #10062 lands.
  • The description says the list fills the exact room with its top at the 16 px gutter and that useLayerKeyboardClearance.test.tsx passes 38 tests, but at this head the top sits at 26 px and that file has 34 tests.

The two fixes above also remove the two new lint warnings in hooks.ts (an unused gutter and a write to a hook argument's node). CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

Claims and files checked

Review mode: full; reason: author-not-engowner

Claims:

  • Fixes #11725, a flipped Selector list under the keyboard: verified for a list flipped while open (SelectorKeyboardInset.a11y.chromium.spec.ts:482 passes; the list ends at 180 px), but a list opened with the keyboard up now regresses (:412 fails).
  • The runtime does not cap a layer placed above its trigger, by design: verified (useLayerKeyboardClearance.ts:280-287; spec:AST-059 FR9).
  • The old flipped margin's gutter clamp stopped the lift: verified (removed at hooks.ts:309); the quoted 298 px figure was measured on the previous approach.
  • The list is capped to the exact room between the top gutter and the keyboard line: false; it is 10 px short (hooks.ts:328).
  • The cap resets on close or when the list is no longer flipped: verified (hooks.ts:329-337); it is also written at the open (hooks.ts:326).
  • The list's end lifts to the keyboard line with its top at the 16 px gutter: partly false; the end reaches 180 px and the top sits at 26 px.
  • All Layer modules match main: verified; no Layer file is in the diff.
  • A Chromium contract case and a patch changeset were added: verified; the new case passes 3 of 3.
  • Selector.test.tsx passes 252 tests: verified.
  • useLayerKeyboardClearance.test.tsx passes 38 tests: false; it has 34 tests here, all passing.
  • Core typecheck is clean: verified (1,208 source files, no errors).
  • ESLint, Prettier, check-sync and changesets are clean: ESLint has no errors but two new warnings in hooks.ts; Prettier is clean; check-sync and changeset coverage were not rerun.
  • Changeset (this pull request): a flipped Selector list shrinks to the room above the keyboard at the top gutter: partly false; it ends above the keyboard but 10 px short of the room.
  • Changeset (from #10062): the selected row stays on the trigger as an option grows, measured again before paint, with no API change: verified (SelectorOverlayGrowth.a11y.browser.spec.ts passes; no public API change).

Files:

  • .changeset/flipped-selector-keyboard-cap.md: "shrinks to the room" is 10 px short.
  • .changeset/selector-overlay-growth.md: #10062's release note; accurate.
  • apps/storybook/stories/Selector.stories.tsx: #10062's story; clear.
  • packages/core/src/Selector/Selector.test.tsx: #10062's case; passes; clear.
  • packages/core/src/Selector/__tests__/SelectorFlippedOverlayKeyboard.a11y.browser.spec.ts: #10062's; passes in Chromium; clear.
  • packages/core/src/Selector/__tests__/SelectorKeyboardInset.a11y.chromium.spec.ts: the new case passes; :412 fails at this head.
  • packages/core/src/Selector/__tests__/SelectorOverlayGrowth.a11y.browser.spec.ts: #10062's; passes in Chromium; clear.
  • packages/core/src/Selector/hooks.ts: cap written at the open, clearance counted twice, two new lint warnings.

Automated review (maintainer link)

Comment thread packages/core/src/Selector/hooks.ts Resolved
Comment thread packages/core/src/Selector/hooks.ts Resolved
@cixzhang

Copy link
Copy Markdown
Contributor

(Posted by Cindy's agent.) Hi @Geervan, thanks for this PR. main has moved, and this branch now conflicts with it in 3 files (apps/storybook/stories/Selector.stories.tsx, packages/core/src/Selector/__tests__/SelectorFlippedOverlayKeyboard.a11y.browser.spec.ts, packages/core/src/Selector/hooks.ts). Could you merge or rebase onto current main? CodeBunny reviews again automatically after you push.

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

Approval waits on an engineering owner's decision, and changes are needed whichever way it goes.

Approval needs an engineering owner to settle the governing spec for this addition: component:Selector FR2 asks the list to end above any software keyboard, while spec:AST-059 FR9 and architecture:layer-runtime INV11 leave a layer placed above its trigger as it is and keep one runtime definition of the viewport caps, so they need to decide whether a flipped list shrinks above the keyboard and whether that cap belongs to the layer runtime or may stay in Selector (with component:Selector naming why the runtime's cap does not fit). An engineering owner records that decision by commenting /approve-spec b2086c072bfcc87535464f0c280df32fa11d5714 on this pull request or by amending those records.

  • Selector/hooks.ts:326 writes the inline cap during the open, before the flipped margin applies, which leaves the runtime's keyboard cap off, so a nine-option list opened with the keyboard already up ends at 296 px, 116 px under the keyboard line, and SelectorKeyboardInset.a11y.chromium.spec.ts:412 fails (it passes on main); writing the cap only once a margin is set fixes it.
  • Selector/hooks.ts:328 subtracts the 10 px clearance from --_layer-keyboard-inset-block-end, which already includes it, so the flipped list is 154 px at 26–180 px instead of filling the 164 px room from the 16 px gutter; dropping that term gives 16–180 px.
  • The title "fix(core): preserve keyboard clearance cap for flipped layers" describes a layer runtime change, but no Layer module changes and only Selector's flipped list is capped, so please retitle it, for example fix(Selector): shrink a flipped list to the room above the software keyboard.
  • The description says the list fills the exact room with its top at the 16 px gutter, that Selector.test.tsx and useLayerKeyboardClearance.test.tsx pass 252 and 38 tests, and keeps Stack: lines for #11725 and #10062, but at this head the top sits at 26 px, those files have 261 and 34 tests, and #10062 has landed, so please update it.

Also worth fixing: the new case's last check reads layer.style.getPropertyValue('--_layer-keyboard-max-block-size'), which is empty on every layer, capped or not, so it cannot fail; reading the computed value would make it meaningful. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

Claims and files checked

Review mode: full; reason: author-not-engowner

Claims:

  • Fixes #11725, a flipped Selector list under the keyboard: verified for a list flipped while open (the new case passes; the list ends at 180 px), but a list opened with the keyboard up now regresses (SelectorKeyboardInset.a11y.chromium.spec.ts:412 fails).
  • The runtime does not cap a layer placed above its trigger, by design: verified (Layer/useLayerKeyboardClearance.ts:280-287; spec:AST-059 FR9).
  • The old flipped margin's gutter clamp stopped the lift: verified (the clamp is removed at hooks.ts:309); the quoted 208, 118 and 298 px figures come from an earlier approach and are not what main shows (the list ends at 216 px there).
  • The list is capped to the exact room between the top gutter and the keyboard line: false; it is 10 px short (hooks.ts:328).
  • The cap resets to the natural height on close or when the list is no longer flipped: verified (hooks.ts:329-337); it is also written during the open (hooks.ts:326).
  • The list's end lifts to the keyboard line with its top at the 16 px gutter: partly false; the end reaches 180 px and the top sits at 26 px.
  • All Layer modules match main: verified; no Layer file is in the diff.
  • A Chromium case for flipping, the keyboard, scrolling, picking an option and the reset was added: verified; it passes 3 of 3, but its cap-variable check cannot fail.
  • A patch changeset was added: verified.
  • Selector.test.tsx passes 252 tests: the count is out of date; 261 tests, all passing.
  • useLayerKeyboardClearance.test.tsx passes 38 tests: false; it has 34 tests, all passing.
  • Core typecheck is clean: verified.
  • ESLint, Prettier, check-sync and changesets are clean: ESLint has no errors but two new warnings in hooks.ts; Prettier, check-sync and the changeset check are clean.
  • The branch is a stack of #11725 and #10062: false; #11725 is the issue and #10062 has landed on main.
  • Changeset: a list that flips above its trigger while open shrinks to the room above the keyboard at the top gutter and stays scrollable: partly false; it ends above the keyboard and scrolls, but 10 px short of the room, with its top below the gutter.

Files:

  • .changeset/flipped-selector-keyboard-cap.md: "shrinks to the room" is 10 px short.
  • packages/core/src/Selector/__tests__/SelectorKeyboardInset.a11y.chromium.spec.ts: the new case passes but does not check that the list fills the room, and its cap-variable check cannot fail; :412 fails at this head.
  • packages/core/src/Selector/hooks.ts: cap written during the open, clearance counted twice, two new lint warnings.

Automated review (maintainer link)

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

Approval waits on an engineering owner's decision, and two fixes are needed whichever way it goes.

Approval needs an engineering owner to settle the governing spec for this addition: component:Selector FR2 asks the list to end above any software keyboard, while spec:AST-059 FR9 and architecture:layer-runtime INV11 leave a layer placed above its trigger as it is and keep one runtime definition of the viewport and keyboard caps that no consumer defines. They decide whether a flipped list shrinks to the room above the keyboard and scrolls, and whether that cap belongs to the layer runtime or may stay in Selector, with component:Selector naming why the runtime's cap does not fit. An engineering owner records that decision by commenting /approve-spec 486ac5f0e4e74659c84530de872afa88ac4cf618 on this pull request or by amending those records; the author may do so if they are an engineering owner.

  • The title "fix(core): preserve keyboard clearance cap for flipped layers" describes a layer-wide change, but no Layer module changes and only Selector's flipped list gains a cap (Selector/hooks.ts:324-338), so please retitle it, for example fix(Selector): shrink a flipped list to the room above the software keyboard.
  • Miss: the Root Cause section's figures (an unshrunk 208 px height, a lift halted at 118 px, a list ending at 298 px) describe an earlier version of this branch; on main the grown list is 200 px and ends at 216 px, 36 px past the 180 px keyboard line, as #11725 reproduces, so please replace them.

Also worth doing: main has moved and this branch now conflicts with it in packages/core/src/Selector/hooks.ts, where the flip is read from the layer's align-self and the list re-measures after a scroll stops, so the rebase needs the Selector keyboard cases run again there; the new case's top check (SelectorKeyboardInset.a11y.chromium.spec.ts:533) asserts only top >= 15.5, so a list that is 10 px short of the room still passes, and asserting the top within 0.5 px of the 16 px gutter would catch it; and Selector/hooks.ts keeps two ESLint warnings, an unused gutter at :294 and a React Compiler mutation warning on the listbox style writes at :328, which returning the cap from the hook and composing it into the listbox's style would remove.

Claims and files checked

Review mode: full; reason: author-not-engowner

Claims:

  • Fixes the flipped-list keyboard occlusion of the linked issue: supported by reading the margin and cap rules, which put the list at 16-180 px in the issue's case; not re-run in this review.
  • The layer runtime does not cap a layer placed above its trigger, by design: verified (Layer/useLayerKeyboardClearance.ts:279-286; spec:AST-059 FR9).
  • The old flipped margin's gutter clamp stopped the lift: verified; the clamp is removed at Selector/hooks.ts:307. The quoted 208, 118 and 298 px figures are false for main, which ends the list at 216 px.
  • The flipped list is capped to the room between the top gutter and the keyboard line: verified by reading; the doubled clearance term is gone, so the cap is the full room.
  • Deferring the inline cap until a margin is set preserves the runtime's cap when a tall list opens with the keyboard already up: verified by reading (Selector/hooks.ts:315-326); the keyboard-first case could not be run here.
  • The cap resets to the natural height on close or when the list is no longer flipped: verified (Selector/hooks.ts:329-337).
  • No Layer module changes: verified; no Layer file is in the diff.
  • A Chromium case covering flipping, the keyboard, scrolling, activation and a clean reset was added: verified; its reset check now reads the computed cap variable and the inline style, and its top check cannot catch a list short of the room.
  • A patch changeset was added: verified, and its wording matches the code.
  • The Selector and keyboard-clearance unit suites pass 261 and 34 tests, the browser spec 19, and the Core typecheck is clean: the counts match the files at this head (19 browser cases counted); none was re-run in this review.
  • ESLint, Prettier, the sync, knowledge and changeset checks are clean: not re-run; by reading, two ESLint warnings remain in Selector/hooks.ts.
  • Changeset: a list that flips above its trigger while open shrinks to the room above the keyboard and stays scrollable: verified by reading.

Files:

  • .changeset/flipped-selector-keyboard-cap.md: clear.
  • packages/core/src/Selector/__tests__/SelectorKeyboardInset.a11y.chromium.spec.ts: the new case covers the path, but its top check cannot catch a list short of the room.
  • packages/core/src/Selector/hooks.ts: the cap itself waits on the owner decision; two ESLint warnings; conflicts with main.

Automated review (maintainer link)

@Geervan Geervan changed the title fix(core): preserve keyboard clearance cap for flipped layers fix(Selector): shrink a flipped list to the room above the software keyboard Nov 25, 2026

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

Approval waits on an engineering owner's decision about which spec governs this fix, and one change is needed if Selector keeps its own cap.

component:Selector FR2 asks a flipped list to end above the software keyboard, while spec:AST-059 FR9 and architecture:layer-runtime INV11 leave a layer placed above its trigger to the layer runtime, uncapped, and allow no consumer-defined cap. An engineering owner decides whether such a list shrinks and whether its cap belongs to the runtime or may stay in Selector, and records it by commenting /approve-spec 3be5dfd4fa5a319d7468656c6d36d511c3b40806 on this pull request or by amending those records; the author may do so if they are an engineering owner.

  • Miss: with no keyboard up, the flipped list's inline cap min(300px, viewport - gutter) (packages/core/src/Selector/hooks.ts:321) replaces the runtime's 100dvb - both gutters cap and is one gutter looser, so in a viewport under 332 px tall, or under 412 px with an app-declared 80 px bottom bar, a long flipped list runs up to 16 px past its layer box; keeping the runtime's cap in the value (for example a ${gutter}px fallback for the keyboard-inset term) and covering a short viewport in the new case would fix it.

The earlier title, root-cause figures, loose top check, rebase conflict and lint warnings are all addressed. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

Claims and files checked

Review mode: full; reason: author-not-engowner

Claims:

  • Fixes the flipped-list keyboard occlusion of the linked issue: supported by reading the margin and cap, which put the list at 16-180 px in the issue's case; not run in this review.
  • The layer runtime leaves a layer placed above its trigger uncapped, by design: verified (Layer/useLayerKeyboardClearance.ts:276-284).
  • On main the grown list stays 200 px and ends at 216 px, 36 px past the 180 px keyboard line, because the flipped margin holds its top at the gutter: verified by reading main's margin against the issue's reproduction.
  • Once a margin is set and the list is flipped, the hook returns a cap to the room between the top gutter and the keyboard line, composed into the listbox style and cleared on close or when the list is no longer flipped: verified (Selector/hooks.ts:321, :336-338; Selector.tsx:1585-1590, :2262-2264); without a keyboard the same cap applies and is looser than the runtime's (finding above).
  • Waiting for a set margin keeps the runtime's cap for a list opened with the keyboard already up: verified by reading (Selector/hooks.ts:329-338).
  • Not subtracting the clearance a second time lets the list fill 16-180 px: verified; the runtime's inset already includes the 10 px clearance (Layer/useLayerKeyboardClearance.ts:239).
  • The unclamped margin lifts the list to the keyboard line with its top at the 16 px gutter: verified by reading (Selector/hooks.ts:320).
  • No Layer module changes: verified.
  • The new Chromium case covers the flip, the keyboard (top within 0.5 px of the gutter, bottom at most 180.5 px), scrolling, picking an option and a clean reset: verified by reading (SelectorKeyboardInset.a11y.chromium.spec.ts:482-572); not run.
  • A patch changeset was added: verified; its wording matches the keyboard path.
  • 265 Selector and 34 keyboard-clearance unit tests, 19 browser cases and a clean typecheck: the 19 browser cases match the spec file; the other counts are consistent with the files; none was re-run.
  • ESLint, Prettier and the sync, knowledge and changeset checks are clean: not re-run; the two lint warnings an earlier review read are gone by reading.
  • Changeset: a list that flips above its trigger while open shrinks to the room above the keyboard and stays scrollable: verified by reading.

Files:

  • .changeset/flipped-selector-keyboard-cap.md: clear.
  • packages/core/src/Selector/Selector.test.tsx: clear; the expectation matches the new margin.
  • packages/core/src/Selector/Selector.tsx: applies the cap; it replaces the runtime's cap on flipped lists (finding above).
  • packages/core/src/Selector/__tests__/SelectorKeyboardInset.a11y.chromium.spec.ts: clear; no case covers a short viewport without a keyboard.
  • packages/core/src/Selector/hooks.ts: the cap waits on the owner decision; finding at line 321.

Automated review (maintainer link)

Comment thread packages/core/src/Selector/hooks.ts Resolved
@Geervan

Geervan commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@cixzhang i am confused, should i wait for your decision on this, without making any changes to it or fix the pointed out bug? the wording is unclear hence the confusion

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

Approval waits on an engineering owner's decision about which spec governs this fix; you do not need to change the code for that decision, and one small update to the description is needed either way.

component:Selector FR2 asks a flipped list to end above the software keyboard, while spec:AST-059 FR9 and architecture:layer-runtime INV11 leave a layer placed above its trigger to the layer runtime and allow no consumer-defined cap, so an engineering owner decides whether such a list shrinks and whether its cap belongs to the runtime or may stay in Selector, and records it by commenting /approve-spec 8cccf634e235e4e2efffd0efb602d22990cf8a92 on this pull request or by amending those records (the author may do so if they are an engineering owner).

  • The description still quotes the cap with a 0px keyboard-inset fallback and reports 19 passing browser cases, while packages/core/src/Selector/hooks.ts:322 now falls back to the gutter and SelectorKeyboardInset.a11y.chromium.spec.ts declares 20 cases, so please update the Solution and Verification sections.

Non-blocking:

  • The new short-viewport case never flips its list: the nine-option list opens below the field already at the runtime's cap and nothing grows or scrolls, so it would pass without the fix; growing an option in Pre Selected until the list reaches the cap, as the #11725 case does, and asserting an inline max-height would make it cover the flipped path.
  • The new comment about the gutter fallback (hooks.ts:317-318) sits on the margin, whose inset falls back to 0px; it belongs above the cap at line 322.

The no-keyboard overrun from the last review is fixed in this push. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

Claims and files checked

Review mode: full; reason: author-not-engowner

  • Claim: a flipped list ends above a keyboard that rises and shrinks to the room there (issue #11725): verified from the code's geometry, 16–180 px in the issue's case; not run.
  • Claim: the layer runtime leaves a layer placed above its trigger uncapped by design: verified in the keyboard clearance hook and the layer specs.
  • Claim: the old flipped margin clamped the list's top with the unshrunk height, leaving its end at 216 px: verified in the base hook.
  • Claim: the cap applies only once a margin is set and the list is flipped while open, and resets on close: verified (hooks.ts:330-339, Selector.tsx:1585-1590).
  • Claim: the quoted cap expression with a 0px fallback: false at this head (hooks.ts:322 uses the gutter).
  • Claim: no duplicate keyboard clearance subtraction, so the list fills 16–180 px: verified (hooks.ts:322).
  • Claim: the flipped margin is unclamped so the list lifts to the keyboard line: verified (hooks.ts:321).
  • Claim: no Layer module changes: verified.
  • Claim: a Chromium case covers flipping, the keyboard, scrolling, picking and the reset, plus a patch changeset: verified (spec lines 482-572, changeset).
  • Claim: 19 browser cases pass: false at this head (20 declared); the unit, typecheck and lint results could not be rerun here.
  • Claim (changeset): a list that flips above its trigger while open shrinks to the room above the keyboard and scrolls: verified against the code.
  • File .changeset/flipped-selector-keyboard-cap.md: clear.
  • File packages/core/src/Selector/Selector.test.tsx: clear.
  • File packages/core/src/Selector/Selector.tsx: clear.
  • File packages/core/src/Selector/__tests__/SelectorKeyboardInset.a11y.chromium.spec.ts: the short-viewport case does not flip its list (non-blocking).
  • File packages/core/src/Selector/hooks.ts: description mismatch above; comment placement (non-blocking).

Automated review (maintainer link)

Comment on lines +317 to +318
// lifts the list's end above a software keyboard. With no keyboard up,
// the inset falls back to the second gutter so both viewport gutters hold.

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.

Non-blocking: this sentence explains the cap's fallback on line 322, but it sits on the margin, whose inset falls back to 0px. Moving it above line 322 keeps each comment on the value it explains, for example: "With no keyboard up, the cap's inset falls back to the gutter. The cap then keeps both viewport gutters."

}).toPass({timeout: 3_000});
});

test('a flipped list in a short viewport with no keyboard stays within both gutters', async ({

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.

Non-blocking: nothing in this case flips the list. At 844×280 the nine options open below the field already at the runtime's 248 px cap (16–264 px), no option grows and nothing scrolls, so listbox.style.maxHeight stays empty and the case checks the runtime's own cap; it would pass without the gutter fallback. Opening Pre Selected and growing an option until the list reaches the cap, as the #11725 case above does, then asserting a non-empty list.style.maxHeight, would put it on the flipped path.

This branch was successfully deployed

1 active deployment
Preview — 8cccf634 Deployed Nov 25, 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. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Selector: a list that flips above its trigger while open can sit under a keyboard that rises after

2 participants