Repository navigation
fix(website): clamp picker maxHeight to available space (#8252) - #8538
Conversation
UX Review (Fable 5) — ✅ PASSUX-level review of All three pickers already scroll the initial selection into view on open, and each applies the clamped UX-Verdict: PASS Pure geometry fix: pickers now scroll inside the viewport instead of clipping past its top; identical rendering at normal viewport sizes. [UX-REVIEWED] 45c0712 |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Clamping maxHeight to the chosen side's real space is the right minimal fix — estimate accuracy becomes irrelevant to clipping, no measurement machinery added. Suggestions
[DESIGN-REVIEWED] 45c0712 |
Opus 4.8 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of All evidence gathered. The clamp lands in the shared helper all three pickers consume; the hand-rolled clamps elsewhere ( First-Principles-Verdict: PASS The clamp fixes the reported clip at cause level — estimate accuracy no longer matters — and every rider is declared, derived, and pinned by a test. What this change shipsIntent: stop picker menus from extending past the viewport edge at short viewports (issue #8252, option 1). This is a FIX.
Watch
[FIRST-PRINCIPLES-REVIEWED] 45c0712 |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
menuGeometry returned a constant maxHeight of MENU_MAX_HEIGHT (320), trusting the count*rowH estimate to fit. Real rows render taller than the estimate (~53px vs 48px), and since #7673 pins an opens-above menu's bottom edge, the surplus extends past the viewport TOP at short viewports instead of covering the composer. Clamp maxHeight to the space actually available on the chosen side (above: rect.top - margin, capped at the viewport for an off-screen anchor; below: innerHeight - rect.bottom - margin), capped at MENU_MAX_HEIGHT and floored at one row + padding + extraH. The estimate still picks the side; when its side cannot show even one row and the other side is roomier, the side flips there (pure rect math, no post-mount measurement). An over-tall menu scrolls inside its container - all three pickers already apply maxHeight to an overflow-y-auto container. Closes #8252
fc9437a to
45c0712
Compare
NicholasRBowers
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: fix with clear root cause — pickerMenu geometry maxHeight was unclamped to the space actually available on the chosen side, letting a menu taller than the estimate clip past the viewport; pure rect math in website/src/lib/pickerMenu.ts plus its test.
Summary
menuGeometry(shared by the @file, $skill, and /command pickers) returned a constantmaxHeight: MENU_MAX_HEIGHT(320), trusting thecount * rowHestimate to fit the chosen side. Real rows render taller than the estimate (~53px measured vs the 48px constant), and since #7673 pins an opens-above menu's bottom edge to grow upward, the surplus extends past the viewport TOP at short viewports (issue worked example: 3 rows atrect.top = 160— 156px available, ~167px real height, 11px off-screen).This implements the reporter's preferred option 1: clamp
maxHeightto the space the chosen side actually has, so estimate accuracy becomes irrelevant to clipping — an over-tall menu scrolls inside its container instead. All three pickers already applymaxHeightto anoverflow-y-autocontainer (FilePicker/SlashCommand on the portal itself, SkillPicker on the inner listbox), so no component changes were needed.What changed (
website/src/lib/pickerMenu.tsonly, plus its test)maxHeight = max(minSensibleHeight, min(MENU_MAX_HEIGHT, available))whereavailableisrect.top − marginabove (capped at the viewport, for an anchor scrolled past the bottom edge) orinnerHeight − rect.bottom − marginbelow.minSensibleHeight = rowH + 8 + extraH: one row plus padding plus pinned chrome (the skill picker's scope footer must not eat the one guaranteed row), so a degenerate anchor never yields a sliver-height menu.rect.top − menuH − margin > 0); only when the chosen side cannot show even one row and the other side is roomier does the side flip there. Pure rect math — no post-mount measurement or reflow machinery (which the issue's option 1 deliberately avoids). Without this, a composer low in a 200px viewport opened below into 12px while 136px sat unused above.minSensibleHeight.Tests (
website/src/test/pickerMenu.test.ts)All #7673 placement tests kept passing unchanged; new cases pin:
rect.top→maxHeight == rect.top − margin(< 320) — no top clipmaxHeight == innerHeight − rect.bottom − marginMENU_MAX_HEIGHTrect.top = 160,rowH = 48→above === true,maxHeight === 156maxHeight = 136instead of below into 12pxbottomfloors at 0) → clamp capped at the viewport, not the off-screenrect.topextraHfunds the floor: skill-picker footer at a hopeless viewport →maxHeight = rowH + 8 + extraHrowH + 8Verified locally:
npx tsc -bandeslintclean. Vitest runs in CI (this host does not run test suites locally by operator policy).Screenshots
Not applicable: the change is invisible at default viewport sizes — with normal space above the composer the clamp resolves to the same 320px cap as before, and the fixed defect (a menu edge a few px past the viewport boundary at short viewports) was itself derived from measurements rather than visually observed (see the issue: "the clipping itself is derived, not observed"). The geometry is pinned exactly by the unit-test matrix above, including the issue's worked example.
Review
Three model-pinned pre-push reviewers (2× GPT lane, 1× Opus lane). Converged finding fixed in this commit: the fits-neither case previously floored past the available space and could still clip; also fixed the viewport over-read for off-screen anchors, the
extraH-less floor, an overstated doc claim, and a test helper that leaked a data property over happy-dom'sinnerHeightaccessor. One cosmetic finding (clamped above-menu renders flush at y=0) rebutted: adding a top gap would break the issue's pinned worked example (maxHeight === 156).Pattern harvest
Rule candidate: review checklist — a positioning helper that returns a FIXED pixel bound (
maxHeight,maxWidth) while placing an element against a viewport edge must derive that bound from the space actually available on the chosen side, not from a constant; a constant bound silently trusts whatever size estimate chose the side. Same shape as this defect:menuGeometryclamped at a 320px constant while the side choice used an estimate that under-read real content. Grep-able signal:maxHeight: <CONSTANT>returned from a function that also readsgetBoundingClientRect().Closes #8252