Skip to content

fix(Selector): keep overlays inside a panned visual viewport - #12227

Open
bezabyte wants to merge 10 commits into
meta:mainfrom
bezabyte:codex/issue-11734-selector-visual-viewport
Open

bezabyte wants to merge 10 commits into
meta:mainfrom
bezabyte:codex/issue-11734-selector-visual-viewport

Conversation

@bezabyte

@bezabyte bezabyte commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #11734

What changed

The visual-viewport pan is handled by the shared keyboard-clearance runtime, and only a layer whose own placement follows the private offset opts into that projection.

  • useLayerKeyboardClearance reads visualViewport.offsetTop once per shared keyboard report and publishes it through the private --_layer-keyboard-visual-viewport-offset-block-start property beside the keyboard inset.
  • A same-height pan keeps the existing cap and commits only the offset; it does not remeasure the layer or rerun anchor fallback on every scroll report.
  • When a keyboard report and a pan arrive together, the runtime measures with the prior offset, applies the new offset and cap together, and corrects the one resulting placed box if needed.
  • Selector opts into the offset because its overlay margin owns the placement. The below-anchor path follows the panned visible top, while the flipped path keeps its gutter floor and moves the keyboard-clearance line with the pan.
  • Ordinary Popovers and menus do not opt in, so a tall anchored Popover keeps its block-start edge and focused field during a pan.
  • Added Layer, Selector Chromium, and Popover browser coverage for these paths, including a flipped-list regression that grows an option, reopens to establish the flipped placement, and then pans the keyboard viewport.

Before and after

On main, a Selector list near the bottom edge can occupy the wrong part of the visible room when a software keyboard pans the visual viewport. The shared layer runtime has no Selector-specific projection, while ordinary Popovers already keep their anchored edge.

After, the shared runtime owns the single keyboard report path. Selector receives the private offset it needs; a flipped list retains its gutter floor while the keyboard line moves with the visual pan. Other layers keep their normal anchored geometry. The tests prove nonzero Selector placement in the panned room and a stable tall-Popover top and field.

Static screenshots would not honestly prove the event ordering and geometry, so the evidence is in the read-count assertion and fresh Chromium placement checks against the Storybook stories.

Shared runtime cost

The layer runtime is shared by layered components, although only Selector opts into the new offset projection. Measured first-load gzip deltas are +348 B on the docs page, +373 B on the form page, +397 B on the menu page, and +369 B on the table page.

Verification

  • Layer/Selector/Popover focused unit tests — 296 passed
  • Selector Chromium keyboard contract — 28 passed
  • Popover Chromium keyboard contract — 11 passed, including the tall-Popover pan case
  • pnpm -F @astryxdesign/core typecheck — passed
  • Targeted ESLint and Prettier — passed
  • Commit repository guards — passed on the previous head
  • Full workspace typecheck remains blocked by the existing charts → cli → charts task cycle.

@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 19, 2026 6:30pm 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 19, 2026, 6:40 PM UTC

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

Changes requested. On the base the list sits entirely above the visible area under a keyboard pan; with this change it lands in view when the keyboard's cap arrives before the pan, but not in the other orders, and the fix needs to live in the shared keyboard path.

  • When the browser's pan comes before the keyboard's cap, or the keyboard changes height after the pan, the list now runs 28–30 px under the keyboard, because the floor in hooks.ts:278-281 overrides the layer runtime's cap, which still draws its keyboard line without the pan (Layer/layerKeyboardClearance.ts:50) and then stands down (Layer/useLayerKeyboardClearance.ts:283-286).
  • Selector adds its own visualViewport resize and scroll listener (hooks.ts:241-255), which architecture:react-component-runtime INV11 rules out ("No Core component keeps its own visual-viewport listener for the keyboard"), so please read the pan offset in the layer runtime's keyboard clearance, once per keyboard report, apply it to the cap, and pass it to Selector as a private custom property beside --_layer-keyboard-inset-block-end.
  • Every visual-viewport scroll and resize now re-runs the whole overlay measurement (anchor rect, list offsets, computed margins), which INV18 and spec:AST-059 FR8 forbid on scroll and resize paths; the same move into the keyboard owner fixes it.
  • The changeset says overlays stay "inside the visible visual viewport", but the code floors only the list's top and the list can end under the keyboard, so reword it to what the tests prove.
  • Please add panned cases (cap then pan, pan then cap, a keyboard change after the pan) to SelectorKeyboardInset.a11y.chromium.spec.ts, since an emitted style string cannot show where the list lands.

The Chromium measurements behind the first point used a stand-in visual viewport at the issue's geometry (863×304, 196 px keyboard, 101.7 px pan), the same technique that spec already uses.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim: the overlay is recomputed when the visual viewport resizes or pans while the list is open: verified (hooks.ts:241-255, :293).
  • Claim: the margin is clamped to the visual viewport's block-start edge: verified for the top (hooks.ts:277-281); the bottom is not kept above the keyboard (first finding).
  • Claim: a regression test covers an initial pan and a later visual-viewport scroll: verified (Selector.test.tsx:648-703; it fails on the base and passes on the head).
  • Claim: a patch changeset is added: verified (@astryxdesign/core patch).
  • Claim (before): the base measured the keyboard's room from the layout viewport only: verified (base hooks.ts, layoutViewportHeight).
  • Claim (after): the list follows the visible viewport while the keyboard is up: false in two of three keyboard-and-pan orders (first finding).
  • Claim: the Selector suite passes with 261 tests: verified (261 in Selector.test.tsx; all 364 tests in the Selector folder pass).
  • Claim: typecheck, lint, format and guard suites pass: partly checked (ESLint, Prettier and the Core build pass; the other suites were not run).
  • Changeset: overlays stay inside the visible visual viewport: false (fourth finding).
  • packages/core/src/Selector/hooks.ts: first, second and third findings.
  • packages/core/src/Selector/Selector.test.tsx: asserts only the emitted margin string (fifth point).
  • .changeset/selector-visual-viewport-pan.md: fourth finding.

Automated review (maintainer link)

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

Copy link
Copy Markdown
Contributor Author

Addressed the requested changes in 0a5f4fd.\n\n- Removed the direct visual-viewport resize/scroll listener from Selector.\n- Moved pan handling into the shared Layer keyboard-clearance runtime, which consumes the existing keyboard-height reports.\n- The runtime now applies the pan to the keyboard cap and exposes it beside the keyboard inset through a private custom property.\n- Selector uses that property for its visible top floor and keyboard-room calculation.\n- Added the same-height pan Layer regression and Chromium cases for cap-then-pan, pan-then-cap, and keyboard-height change after pan.\n- Reworded the changeset to match the behavior now proven.\n\nVerification: Layer 35/35, Selector 260/260, Chromium 16/16, Core typecheck, targeted lint/format, repository guards, and commit hook passed. The existing reviewer/spec-owner approval gate is still the only remaining external action.

@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 requested. Moving the pan into the layer runtime removes Selector's own listener and keeps the list's bottom on the panned keyboard line, but at the issue's own geometry the list now collapses, and the pan path does layout work on every scroll event.

  • At the issue's geometry (863×304, 196 px keyboard, 101.7 px pan), the keyboard-then-pan, one-report and opened-while-panned orders each leave the open list 0 px tall at the visible top in Chromium (13 px after a later keyboard change), because capFor releases the cap with the new offset (Layer/useLayerKeyboardClearance.ts:270-275), Selector's floor (Selector/hooks.ts:259) then makes the uncapped list overflow so the fallback order flips it above the trigger, and the cap computed from that flipped box is max(0, 199.7 − 226.3) = 0 (Layer/layerKeyboardClearance.ts:59).
  • Each visual-viewport scroll event that moves offsetTop while the keyboard is up re-runs the whole cap measurement for every open anchor-mode layer (Layer/useLayerKeyboardClearance.ts:481-498; in Chromium three box reads and five style writes per event, plus a forced flip), which spec:AST-059 FR8 and FR10 and architecture:react-component-runtime INV18 rule out on a scroll path, so please carry the pan to the cap without measuring the layer on each report (for example through the offset property the runtime already writes) or measure once when the pan settles.
  • The three new Chromium cases (SelectorKeyboardInset.a11y.chromium.spec.ts:351-425) also pass against a build of the base branch, because at 390×844 the base list already sits inside the panned band and the cases never check the list's top or height, so they do not back "Fixes #11734"; please add the issue's geometry as a case that fails on the base and asserts the list's top, bottom and non-zero height against the panned band.

The inline comments carry the measurements and two small comment suggestions.

Claims and files checked

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

  • Claim: the layer runtime reads the pan on each shared keyboard report and includes it in the cap: verified (useLayerKeyboardClearance.ts:481-498, :283-288); it reads visualViewport.offsetTop itself on each report.
  • Claim: the runtime publishes the pan through a private property beside the keyboard inset: verified (useLayer.tsx:112-113, :2541).
  • Claim: Selector uses that property for its visible top floor and its keyboard line: verified (Selector/hooks.ts:258-259).
  • Claim: Selector no longer keeps its own visual-viewport listener: verified (Selector/hooks.ts).
  • Claim: a Layer regression covers a same-height pan: verified (useLayerKeyboardClearance.test.tsx:715-757).
  • Claim: the rendered placement proof moved to the Chromium contract, with cap-then-pan, pan-then-cap and keyboard-change-after-pan cases: false; the cases exist but pass on the base build (third finding).
  • Claim: the runtime updates the cap once for a same-height pan: partly; once per report, so a pan of many scroll events re-measures on each (second finding).
  • Claim: the changeset describes the behavior in terms of the keyboard line: verified; the list's bottom stays on the line in every order measured.
  • Claim: Layer 35, Selector 260 and Chromium 16 tests pass: verified (295 unit tests, 16 Chromium cases).
  • Claim: Core typecheck, targeted lint and format pass: verified (tsc --noEmit, ESLint, Prettier); repository guards and the commit hook were not run.
  • Claim: fixes the linked issue: false at the issue's geometry (first and third findings).
  • Changeset: keeps Selector overlays above the keyboard line under a pan: verified for the list's bottom edge.
  • .changeset/selector-visual-viewport-pan.md: clear.
  • packages/core/src/Layer/layerKeyboardClearance.ts: first finding (a flipped box clamps the cap to 0).
  • packages/core/src/Layer/useLayer.tsx: clear.
  • packages/core/src/Layer/useLayerKeyboardClearance.test.tsx: clear.
  • packages/core/src/Layer/useLayerKeyboardClearance.ts: first and second findings; two comment suggestions inline.
  • packages/core/src/Selector/Selector.test.tsx: clear (pins the new margin strings).
  • packages/core/src/Selector/__tests__/SelectorKeyboardInset.a11y.chromium.spec.ts: third finding.
  • packages/core/src/Selector/hooks.ts: first finding (the floor).

Automated review (maintainer link)

@bezabyte

Copy link
Copy Markdown
Contributor Author

Addressed the second review pass in ca30a4e04.

  • The cap measurement keeps the prior visual-viewport offset while it reads the layer, then applies the new offset and cap together. A single placed-box correction handles the Selector floor without releasing into a different anchor fallback.
  • A same-height visual-viewport pan now commits only the private offset. It does not call avoid, read the layer box, or rerun the cap on every scroll report.
  • The Layer regression now checks both that the cap stays unchanged and that the pan causes no additional layer-box reads.
  • Added the requested 863x304, 196px, 101.7px issue-geometry case with assertions for list top, bottom, and nonzero height. The full Chromium contract is now 17/17.

The Core typecheck, targeted lint/format, repository guards, and commit hook also pass.

@bezabyte

Copy link
Copy Markdown
Contributor Author

The requested changes are now on ca30a4e04. Please re-review this head when convenient; the assigned reviewers remain cixzhang, imdreamrunner, and josephfarina.

@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 requested. A pan that arrives on its own now moves the open list into the visible area with no layout read per pan report, but two of the issue's own orders still leave the list off-screen.

  • The keyboard-cap lift at Layer/useLayerKeyboardClearance.ts:346-356 moves the layer back by exactly the pan, so at the issue's geometry (863×304, 196 px keyboard, 101.7 px pan) a keyboard report that brings the pan, or a list opened on a panned page, still sits at 0–98 px above the visible area; compare the placed box with the box at the new offset so the lift never undoes Selector's floor.
  • The new Chromium cases pass unchanged against a build of the base branch because they assert top >= 0 (SelectorKeyboardInset.a11y.chromium.spec.ts:234, :244) rather than a top at or below offsetTop, so the description's claim that the issue-sized test keeps the list in the panned band, and "Fixes #11734", do not hold yet.
  • Miss: the changeset's "Keep Selector overlays above the keyboard line" describes what the base already does, since its list always ends above the panned keyboard line, so please describe the actual change, for example "Keep an open Selector list inside the visible area, above the keyboard, when a software keyboard pans the page."

Two comments in the runtime are non-blocking suggestions, noted inline. 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, changeset: overlays stay above the keyboard line under a pan. False as a change: the base list already ends above the panned line in every order measured.
  • Claim: the runtime reads the pan from keyboard reports and publishes it through a private property beside the inset. Verified (useLayerKeyboardClearance.ts:552-574, useLayer.tsx:2541).
  • Claim: a same-height pan keeps the cap and commits only the offset, with no remeasure. Verified (useLayerKeyboardClearance.ts:571-573; the new Layer test; no layer box reads over 20 pan reports in Chromium).
  • Claim: a keyboard report with a pan measures at the prior offset and applies the new offset and cap together. Verified for the cap, but the outcome fails: the lift then returns the list above the visible area (:346-356).
  • Claim: Selector uses the property for its visible top floor and panned keyboard line. Verified (hooks.ts:258-259).
  • Claim: a Layer regression proves a same-height pan reads no layer box. Verified (useLayerKeyboardClearance.test.tsx:716-763, passes).
  • Claim: Chromium coverage for cap then pan, pan then cap, a keyboard change after a pan, and the issue geometry. Present, but every case also passes on the base build.
  • Claim: the issue-sized test proves the list keeps a nonzero box in the panned band. False: in that order the list sits above the band.
  • Claim: the pull request fixes the linked issue. False at this head for two orders.
  • Claim: Layer unit tests 35 passed and the Selector Chromium contract 17 passed. Verified.
  • Claim: Core typecheck, targeted lint and format pass, and Storybook rebuilds. Verified; repository guards and the commit hook were not rerun.
  • File .changeset/selector-visual-viewport-pan.md: finding (describes base behavior).
  • File packages/core/src/Layer/layerKeyboardClearance.ts: clear.
  • File packages/core/src/Layer/useLayer.tsx: clear.
  • File packages/core/src/Layer/useLayerKeyboardClearance.ts: finding (lift undoes the pan); two non-blocking comment notes.
  • File packages/core/src/Layer/useLayerKeyboardClearance.test.tsx: clear.
  • File packages/core/src/Selector/Selector.test.tsx: clear.
  • File packages/core/src/Selector/__tests__/SelectorKeyboardInset.a11y.chromium.spec.ts: finding (assertions pass on the base).
  • File packages/core/src/Selector/hooks.ts: clear.

Automated review (maintainer link)

@bezabyte

Copy link
Copy Markdown
Contributor Author

Addressed the latest requested changes in 79d04a901.

  • The keyboard-cap lift now compares the placed layer with its projected box in the new visual viewport. An intentional visual-viewport pan is no longer mistaken for fallback repositioning, so the layer is not lifted back out of the visible room.
  • Added issue-sized Chromium coverage for cap-first, pan-first, and keyboard-height-change-after-pan ordering. The assertions require all four options to remain present, a nonzero list box, a top at or below the reported panned offset, and a bottom above the panned keyboard clearance line.

Verification:

  • Chromium selector keyboard-inset spec: 20 passed
  • Focused Layer/Selector unit tests: 295 passed
  • Core typecheck, repository checks, ESLint, and Prettier: passed

Please review the current head.

@bezabyte

Copy link
Copy Markdown
Contributor Author

One final review wording item is also addressed in a9985b725: the changeset now describes the actual fix — keeping an open Selector list inside the visible area, above the keyboard, when the software keyboard pans the page.

@bezabyte

Copy link
Copy Markdown
Contributor Author

Follow-up in e0f39f81e:

  • The issue-sized cases now drive the checked-in Selector › Overlay Beside Keyboard story, including the keyboard-and-pan-together and already-panned-open orders, instead of a generic fixture.
  • Removed the inaccurate comment describing this runtime as the visual-viewport listener owner; the keyboard guide owns the listener and this runtime consumes its report.

Fresh Storybook verification: all 22 Chromium cases pass at 863×304 with the issue's 196px cover and 101.7px offset. The focused Layer/Selector unit suite remains 295/295.

…tor-pan

# Conflicts:
#	packages/core/src/Selector/__tests__/SelectorKeyboardInset.a11y.chromium.spec.ts
#	packages/core/src/Selector/hooks.ts
@bezabyte

Copy link
Copy Markdown
Contributor Author

The branch is now rebased into a mergeable state through c7c1e1b25, which includes current origin/main and resolves the Selector conflicts without dropping either the upstream resize/flip behavior or the visual-viewport pan fix.

Final verification on the merged tree:

  • Pre-review audit: 0 findings; merge into origin/main: clean
  • Focused Layer/Selector unit tests: 296 passed
  • Fresh Storybook build: passed
  • Chromium keyboard-inset contract: 27 passed, including the upstream cases and the issue-specific 863×304 / 196px / 101.7px cases
  • Commit hook and repository checks: passed

@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 requested. An open default Selector list now lands in the visible area above the keyboard at the linked issue's geometry, and the issue's own reproduction is fixed, but two neighbouring paths regress under a pan.

  • Selector/hooks.ts:310 adds the pan to the flipped margin, which a flip measures from the anchor's top up to the list's end, so a list flipped above its field while open moves up by the pan (a 300 px list sits at 84–384 px under a 150 px pan, its first 66 px above the visible area, where main keeps it at 234–534 px); please subtract the pan there, floor the flipped list's top at the pan, and add a Chromium case that flips the list and then pans.
  • The pan projection in Layer/useLayerKeyboardClearance.ts:311-358 shifts every layer's box by the pan although only Selector's overlay follows it, so a tall Popover stops keeping its block-start edge, as the layer viewport inset record requires, when the keyboard report brings a pan (its top and focused field move from 16 px to 56 px under a 40 px pan, where main holds them); please project only a layer that places itself by the offset and add a pan to the tall-popover browser case.
  • The changeset's "Keep an open Selector list inside the visible area" covers every open list while the tests cover only a list that opens below its field, so please fix the flipped path so the note holds, or narrow it.
  • The description's "Before, Selector listened to visual-viewport resize and scroll events itself" describes this pull request's first commit rather than main, and "without layout reads" leaves out the one visualViewport.offsetTop read per report, so please reword both.

Four smaller suggestions are noted inline. 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:

  • Changeset: keeps an open list in the visible area above a panned keyboard. Verified for a list that opens below its field: six issue-geometry cases fail on main and pass here. False for a list flipped while open (Selector/hooks.ts:310).
  • Fixes the linked issue: verified. The issue's own story and geometry put the list at 101.7–199.7 px; main puts it at 0–98 px.
  • The runtime reads the pan on each keyboard report and publishes it as a private property beside the inset: verified (useLayerKeyboardClearance.ts:557-574, useLayer.tsx:2541).
  • A same-height pan keeps the cap and commits only the offset, measuring no layer box: verified (useLayerKeyboardClearance.ts:571-573; the unit test passes).
  • A keyboard report with a pan measures at the prior offset, applies the offset and cap together and corrects the placed box: verified for Selector. False for other anchor-mode layers (useLayerKeyboardClearance.ts:311-358).
  • Selector uses the property for its top floor and panned keyboard line and keeps main's resize and flipped behavior: verified below the field (hooks.ts:303). False for the flipped margin (hooks.ts:310).
  • A Layer regression proves a same-height pan reads no layer box: verified (useLayerKeyboardClearance.test.tsx:716-763 passes).
  • Chromium coverage at the issue geometry for five orders: verified. All 27 cases pass here; the six issue cases fail on main.
  • Before, Selector listened to visual-viewport events itself: false for main. That listener existed only in this pull request's first commit.
  • After, a steady pan updates the offset without layout reads: partly false. No layer box is read, but visualViewport.offsetTop is read once per report (useLayerKeyboardClearance.ts:561).
  • Unit tests, Chromium contract and Storybook build pass: verified. The Layer and Selector Vitest folders pass 1,056 tests, the Chromium contract passes 27 of 27, and Storybook builds.
  • Clean merge into current main: verified.
  • Core typecheck, targeted ESLint and Prettier pass: verified.
  • Pre-review audit, repository guards and commit hook: not re-run.

Files:

  • .changeset/selector-visual-viewport-pan.md: finding (it claims more than the tests prove).
  • packages/core/src/Layer/layerKeyboardClearance.ts: clear.
  • packages/core/src/Layer/useLayer.tsx: clear.
  • packages/core/src/Layer/useLayerKeyboardClearance.test.tsx: clear.
  • packages/core/src/Layer/useLayerKeyboardClearance.ts: finding (the pan projection applies to every layer); non-blocking notes inline.
  • packages/core/src/Selector/Selector.test.tsx: clear.
  • packages/core/src/Selector/__tests__/SelectorKeyboardInset.a11y.chromium.spec.ts: clear; a repeated header sentence is noted inline.
  • packages/core/src/Selector/hooks.ts: finding (the flipped margin adds the pan where it should subtract it).

Automated review (maintainer link)

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

Copy link
Copy Markdown
Contributor Author

Addressed the requested pan review.

The flipped Selector formula now subtracts the visual-viewport pan and floors the list against the panned top. The layer runtime only projects the pan for an explicitly opted-in self-positioned layer, so ordinary Popovers keep their block-start edge. The keyboard-report guard also avoids publishing an offset after the keyboard has ended.

Added the tall-Popover pan regression and kept the issue-sized Selector cases covering cap-first, pan-first, combined, already-panned, and post-pan keyboard-height changes. Verification: 296 focused unit tests, 27 Selector Chromium cases, and 11 Popover Chromium cases passed; Core typecheck, targeted ESLint/Prettier, and repository guards passed.

@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 requested. A default Selector list that opens below its field now lands in the visible area above a panned keyboard at the linked issue's geometry, and Popovers and menus keep their placement, but the new floor for a list flipped above its field regresses that path.

  • Selector/hooks.ts:310 floors a flipped list's top at Math.max(gutter, offset), where offset is the selected-item shift rather than the visual viewport's pan, so a flipped list taller than about half the room now ends under the keyboard (the existing case at SelectorKeyboardInset.a11y.chromium.spec.ts:426 fails with the list at 296–584 px against a 534 px clearance line) or past the window's end with no keyboard at all (208–408 px in an 844×390 window, where main keeps 174–374 px); please floor the top at max(gutter, pan) in CSS, drop the outer max(…) copied from the below-anchor margin, and add a Chromium case that flips the list and then pans.
  • The description says the flipped formula keeps the list in the panned room, that the new coverage includes flipped-list behavior and that 27 Selector Chromium cases pass, and the changeset says an open list stays above a panned keyboard, but at this head a tall flipped list ends under the keyboard and 26 of 27 cases pass; please fix the flipped path and report the counts the head gives.
  • The description's Before paragraph describes this pull request's earlier commits (a collapsed list, a projection that moved a tall Popover) rather than main, where the list sits at 0–98 px above the visible area and a tall Popover already holds its edge; please describe main.
  • Miss: the layer runtime is shared by every layered component and grows by code only Selector uses, and the component import boundaries record (INV10) asks such a change to state its first-load cost on the four reference pages, which the description does not (measured here at +348 B, +373 B, +397 B and +369 B gzip for the docs, form, menu and table pages); please add those numbers.

Three smaller suggestions are inline. 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 linked issue for a list that opens below its field: verified. Six issue-geometry Chromium cases pass here and fail on main.
  • The runtime reads the pan once per keyboard report and publishes it as a private property beside the inset: verified for Selector's overlay (useLayerKeyboardClearance.ts:555-582, useLayer.tsx:2549). A report that changes the keyboard's height also reads it in avoid() (:419-423).
  • A same-height pan keeps the cap and commits only the offset, with no layer read: verified (:574-581; the unit test at useLayerKeyboardClearance.test.tsx:718 passes).
  • A keyboard report that brings a pan measures at the prior offset, applies the offset and cap together and corrects the placed box: verified for Selector (the issue cases pass).
  • Selector's below-anchor and flipped formulas keep the list between the panned top and the clearance line: verified below the field (hooks.ts:303). False for the flipped formula (hooks.ts:310).
  • Ordinary Popovers and menus do not opt in, so a tall Popover keeps its edge and field during a pan: verified (PopoverKeyboard.interaction.browser.spec.ts:646 passes; a tall Popover holds 16 px with a pan in the keyboard's own report).
  • Added coverage for the issue geometry and flipped-list behavior: verified for the issue geometry. False for flipped lists: no added case flips the list.
  • Before, a panned report could collapse the list, and a projection moved a tall Popover: false for main. Both describe this pull request's earlier commits.
  • After, other layers keep their geometry and the tests prove Selector placement and a stable Popover: verified.
  • Focused unit tests pass: verified (the Layer, Selector and Popover folders pass 1,205 tests).
  • Selector Chromium contract, 27 passed: false. 26 of 27 pass; the grown-option flipped case at :426 fails.
  • Popover Chromium contract, 11 passed: verified.
  • Core typecheck, targeted ESLint and Prettier: verified.
  • Repository guards and the workspace typecheck cycle: not re-run.
  • Changeset: an open list stays in the visible area above a panned keyboard. Verified below the field; false for a tall flipped list (hooks.ts:310).

Files:

  • .changeset/selector-visual-viewport-pan.md: finding (claims the flipped path).
  • packages/core/src/Layer/layerKeyboardClearance.ts: clear.
  • packages/core/src/Layer/useLayer.tsx: clear; a comment wrap is noted inline.
  • packages/core/src/Layer/useLayerKeyboardClearance.test.tsx: clear.
  • packages/core/src/Layer/useLayerKeyboardClearance.ts: clear; a comment is noted inline; its growth needs the size numbers.
  • packages/core/src/Popover/__tests__/PopoverKeyboard.interaction.browser.spec.ts: clear; a stronger order is noted inline.
  • packages/core/src/Popover/usePopover.tsx: clear.
  • packages/core/src/Selector/Selector.test.tsx: clear.
  • packages/core/src/Selector/Selector.tsx: clear.
  • packages/core/src/Selector/__tests__/SelectorKeyboardInset.a11y.chromium.spec.ts: finding (its flipped case fails here; the header claims it holds).
  • packages/core/src/Selector/hooks.ts: finding (the flipped floor).

Automated review (maintainer link)

Comment thread packages/core/src/Selector/hooks.ts Resolved
});
}

test('a tall popover does not follow a visual-viewport pan', async ({page}) => {

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 pans with a same-height report after the cap, which only publishes the offset and never moved a Popover, so it passes on main too. The last review's regression came from a keyboard report that brings the pan. Raising the keyboard with keyboard(page, COVER, 40) as the first report would guard that path. The head holds 16 px there.

Comment on lines +304 to +307
// A layer that owns its placement can follow a pan by the same amount
// as the visual viewport. Use that projected box for the one cap
// calculation that accompanies a keyboard report; the steady-state pan
// path below only publishes the offset and never reads the box.

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 (INV29): the second sentence has 27 words and two topics. Suggested: "Selector's overlay follows the pan. Its box at the new offset is the measured box moved by the pan. A same-height pan only publishes the offset."

// not inherit it. All three are private runtime state, never set by an app
// not inherit it. The visual viewport's block-start offset sits beside it
// for layers that own their placement. All four are private runtime state,
// never set by an app

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 line ends the comment mid-sentence ("never set by an app" / "or a theme."). Reflow it onto one line.

@bezabyte

Copy link
Copy Markdown
Contributor Author

Addressed the follow-up visual-viewport review on commit 56a742a. The flipped Selector formula now uses the gutter floor and the visual pan in CSS, without reusing the selected-row offset or the below-anchor outer max. Added a Chromium regression that opens a flipped list, then pans the keyboard viewport. The Selector contract passes 28/28; focused unit tests pass 296/296 and Core typecheck plus targeted lint/format checks are clean.

@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 requested. The pan fix now keeps a Selector list below its field, and a flipped list in landscape, inside the visible area, and the last review's flipped-floor regression is gone, but the flipped path's new test and description claim more than the head does.

  • The case "a flipped list stays above a panned keyboard" (SelectorKeyboardInset.a11y.chromium.spec.ts:409) grows no option, so the list never flips and the case passes on main too; please grow an option first as the case at :445 does, use a geometry where main leaves the visible room (844×390 with a 200 px keyboard and a 100 px pan puts the list at 16–180 px on main and 116–280 px here), and assert that the list's top is at or below the visual viewport's offsetTop.
  • The description says the flipped path floors the list at the visual pan, but Selector/hooks.ts:310 keeps the gutter floor, so a flipped list taller than the panned room sits at 76–280 px against a 100 px visible top after a same-height pan; please describe the flipped path as moving its keyboard line by the pan and keeping the gutter floor, and word the changeset to match.

Three earlier non-blocking suggestions remain open inline. 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 linked issue: verified. Six issue-geometry Chromium cases pass here and fail on main.
  • The layer runtime reads the pan on each keyboard report and publishes it as a private property beside the inset: verified for Selector's overlay (useLayerKeyboardClearance.ts:556-582, useLayer.tsx:2549). A report that changes the keyboard's height also reads it in avoid().
  • A same-height pan keeps the cap and only publishes the offset: verified (useLayerKeyboardClearance.ts:574-581; the unit test at useLayerKeyboardClearance.test.tsx:718 passes).
  • A keyboard report that brings a pan measures at the prior offset, applies offset and cap together and corrects the placed box: verified (the issue cases pass; a tall flipped landscape list is capped to 116–280 px).
  • Selector opts in because its overlay margin owns its placement: verified (Selector.tsx:1451).
  • Both formulas keep the list between the panned visible top and the clearance line: verified below the field (hooks.ts:303). False for the flipped formula's top, which keeps the gutter floor (hooks.ts:310).
  • Popovers and menus do not opt in, so a tall Popover keeps its edge and field under a pan: verified (PopoverKeyboard.interaction.browser.spec.ts:646 passes).
  • Added coverage includes an explicit flipped-list-then-pan regression: false. The case at SelectorKeyboardInset.a11y.chromium.spec.ts:409 never flips the list and passes on main.
  • Before: on main the list sits in the wrong part of the panned room, while Popovers keep their edge: verified (the list sits at 0–98 px against a 101.7 px visible top).
  • After: the flipped path floors the list at the visual pan: false. It floors at the gutter.
  • The tests prove nonzero Selector placement in the panned room and a stable tall Popover: verified.
  • Shared runtime cost of +348 B, +373 B, +397 B and +369 B gzip on the four reference pages: verified. The layer runtime is unchanged since these numbers were measured against the same base.
  • Focused unit tests pass: verified (the Layer, Selector and Popover folders pass 1,205 tests).
  • Selector Chromium keyboard contract, 28 passed: verified.
  • Popover Chromium keyboard contract, 11 passed: verified.
  • Core typecheck, targeted ESLint and Prettier pass: verified.
  • Repository guards and the workspace typecheck cycle: not re-run.
  • Changeset: an open list stays inside the visible area above a panned keyboard: verified in every measured order except a flipped list taller than the panned room after a same-height pan.

Files:

  • .changeset/selector-visual-viewport-pan.md: finding (overstates the flipped case; see the second bullet).
  • packages/core/src/Layer/layerKeyboardClearance.ts: clear.
  • packages/core/src/Layer/useLayer.tsx: clear; a comment wrap is still noted inline.
  • packages/core/src/Layer/useLayerKeyboardClearance.test.tsx: clear.
  • packages/core/src/Layer/useLayerKeyboardClearance.ts: clear; a comment is still noted inline.
  • packages/core/src/Popover/__tests__/PopoverKeyboard.interaction.browser.spec.ts: clear; a stronger report order is still noted inline.
  • packages/core/src/Popover/usePopover.tsx: clear.
  • packages/core/src/Selector/Selector.test.tsx: clear.
  • packages/core/src/Selector/Selector.tsx: clear.
  • packages/core/src/Selector/__tests__/SelectorKeyboardInset.a11y.chromium.spec.ts: finding (the flipped case never flips).
  • packages/core/src/Selector/hooks.ts: finding (the description misstates the flipped floor); the code conforms.

Automated review (maintainer link)

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

test('a flipped list stays above a panned keyboard', async ({page}) => {

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.

This case grows no option, so the browser never flips the list: the layer keeps position-area: self-end span-self-end and the below-anchor margin, so it never runs the flipped margin at hooks.ts:310. It also passes against a build of main, where the list sits at 398–534 px inside the panned 634 px line. Please grow an option first, as the case at :445 does, at a geometry where main leaves the visible room: in an 844×390 window with a 200 px keyboard and a 100 px pan, main puts the flipped list at 16–180 px and this branch at 116–280 px. Then assert top >= offsetTop - 0.5, as expectPannedGeometry does, rather than top >= 0.

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

Copy link
Copy Markdown
Contributor Author

Addressed the latest review on ac90fc0. The regression now uses 844×390 landscape geometry, grows an option, closes and reopens to establish the flipped placement, then pans by 100px. It asserts that the list remains inside the panned visible room. I also updated the changeset and PR description to describe the flipped path accurately: it retains its gutter floor while its keyboard-clearance line follows the pan. The full Selector Chromium contract passes 28/28; targeted lint/format and repository guards are clean.

@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: the fix works for the reported case (an open Selector list now sits inside the visible area above a panned keyboard, in the issue's own scene and for a list flipped above its field), but the new flipped-list regression does not exercise the flipped path.

  • The case "a flipped list stays above a panned keyboard" (SelectorKeyboardInset.a11y.chromium.spec.ts:409) closes and reopens the list after growing an option, and a reopen always places the list below its field (Selector/hooks.ts:319-321), so it runs the below-anchor margin and never the flipped margin at :310 that the description and changeset say it guards.

To fix it, grow the option while the list stays open, as the case at :448 does; with the Pre Selected story pinned near the end at 844×390, option 0 grown to 60 px, then a 200 px keyboard with a 100 px pan, the list flips and sits at 116–280 px on this branch against 16–180 px on main. CI has not run on this head yet.

Claims and files checked

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

  • Claims:
    • The runtime reads the visual viewport's pan on keyboard reports and publishes it beside the keyboard inset as a private property: verified (useLayerKeyboardClearance.ts:555-582, useLayer.tsx:112).
    • A same-height pan keeps the cap and republishes only the offset, with no new measurement or fallback: verified (useLayerKeyboardClearance.ts:574-581; unit test at useLayerKeyboardClearance.test.tsx:718).
    • A keyboard report that brings a pan measures at the prior offset, applies offset and cap together, and corrects the placed box once: verified (useLayerKeyboardClearance.ts:283-338, :387-415).
    • Selector opts in; below its field the list follows the panned top, and a flipped list keeps its gutter floor while its keyboard line follows the pan: verified (Selector.tsx:1451, hooks.ts:303, hooks.ts:310; a flipped list sits at 116–280 px).
    • Popovers and menus do not opt in, so a tall Popover keeps its top and field during a pan: verified (useLayer.tsx:1311-1312; PopoverKeyboard.interaction.browser.spec.ts:646, which also passes on main).
    • The added coverage includes a flipped-list regression that grows an option, reopens to establish the flip, then pans: false (the reopen restores the below-anchor placement).
    • On main the list sits in the wrong part of the visible room under a pan, while Popovers keep their edge: verified (0–98 px against a 101.7 px visible top).
    • The shared runtime adds +348 B, +373 B, +397 B and +369 B gzip on the four reference pages: verified (the runtime is unchanged since those numbers were measured).
    • Selector Chromium contract 28 passed, Popover Chromium contract 11 passed, Core typecheck, ESLint and Prettier: verified; the Layer, Selector and Popover unit folders pass (1,205 tests).
    • Changeset: the list stays inside the visible area above a panning keyboard, and flipped lists keep their gutter floor while their clearance line follows the pan: matches the code; the flipped part has no test that exercises it (finding above).
    • Fixes #11734: verified in the issue's own scene.
  • Files:
    • .changeset/selector-visual-viewport-pan.md: clear
    • packages/core/src/Layer/layerKeyboardClearance.ts: clear
    • packages/core/src/Layer/useLayer.tsx: clear (non-blocking: a comment line breaks mid-sentence at :98)
    • packages/core/src/Layer/useLayerKeyboardClearance.ts: clear (non-blocking: comment at :304-307)
    • packages/core/src/Layer/useLayerKeyboardClearance.test.tsx: clear
    • packages/core/src/Popover/usePopover.tsx: clear
    • packages/core/src/Popover/__tests__/PopoverKeyboard.interaction.browser.spec.ts: clear (non-blocking: the pan case passes on main)
    • packages/core/src/Selector/Selector.tsx: clear
    • packages/core/src/Selector/Selector.test.tsx: clear
    • packages/core/src/Selector/hooks.ts: clear
    • packages/core/src/Selector/__tests__/SelectorKeyboardInset.a11y.chromium.spec.ts: finding (the case at :409)

Automated review (maintainer link)

Comment on lines +416 to +418
await page.keyboard.press('Escape');
await expect(page.getByRole('listbox')).toBeHidden();
await trigger.click();

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.

Closing and reopening here undoes the flip: a fresh open always takes the below-anchor margin (Selector/hooks.ts:319-321, comment at :312-316). After this reopen the layer keeps position-area: self-end span-self-end and the :303 margin through the keyboard report, and the list ends at 100–280 px, so the flipped margin at :310 never runs. Please grow the option while the list stays open, as :448 does. The tall story runs under the keyboard once flipped (16–316 px here and on main, since a flipped list taller than the room is not capped), so use the Pre Selected story pinned near the end in 844×390 with option 0 grown to 60 px: after a 200 px keyboard with a 100 px pan the list flips and sits at 116–280 px here and 16–180 px on main.

This branch was successfully deployed

1 active deployment
Preview — ac90fc04 Deployed Nov 19, 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

2 participants