Repository navigation
[select] Fix scroll arrows stopping short of the edges - #4447
Conversation
commit: |
Bundle size report
Check out the code infra dashboard for more information about this PR. |
0fb814b to
54aebef
Compare
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
bb36252 to
9f488de
Compare
9f488de to
a744970
Compare
Codex Review (GPT-5.4)This is a 1. Bugs / Issues (None)2. Root Cause & Patch AssessmentThe fix now addresses the two concrete failure modes that were showing up under constrained fractional layouts:
The shared 3. Pattern Consistency AssessmentThe branch is more internally consistent than the base version:
That consistency matters here because the original bug was essentially a disagreement between neighboring pieces of scroll logic under fractional measurements. 4. Simplification OpportunitiesThe recent simplification pass looks appropriate and bounded. In particular:
I don’t see another obvious simplification that would materially shrink complexity without also making the edge-case behavior harder to follow. 5. Edge Cases Worth NotingThe branch now explicitly handles the cases I would most worry about for this bug class:
I did not find a nearby unhandled path in the same family that looks likely to regress this fix. 6. Test Coverage AssessmentThe added regression coverage now looks meaningful rather than merely plausible:
The subagent test sweep also came back with no remaining brittleness or “passes for the wrong reason” issues after the follow-up cleanup. Merge Confidence ScoreOverall merge confidence is 4/5. I’m highly confident the branch now fixes the reported fractional-scroll bug class and that the regression tests are targeting the real invariants, with only the usual residual risk that comes from DOM-measurement-heavy interaction logic. I’d be comfortable merging this as-is. |
flaviendelangle
left a comment
There was a problem hiding this comment.
Review: PR #4447 — [select] Fix scroll arrows stopping short of the edges
Fixes #4444. Select scroll arrows stop before reaching the true start/end when fractional scroll positions occur (e.g., at non-default browser zoom).
What's Good
-
Shared
scrollEdgesutility — MovingscrollEdges.tsfromscroll-area/utils/tosrc/utils/is correct. Both Select and ScrollArea need this logic, centralizing avoids duplication. -
getMaxScrollOffsethelper — Clean extraction of theMath.max(0, scrollHeight - clientHeight)pattern repeated across files. -
Unified top/bottom scroll logic in
SelectPopup— The refactoredhandleScrollcollapses duplicatedisTopPositioned/isBottomPositionedbranches into shared logic with direction-specific tweaks. Meaningful reduction in duplication. -
Extracted
getTargetScrollTopinSelectScrollArrow— Pulling item-scanning logic out of the inline handler into a standalone function improves readability significantly. The old code had deeply nested direction-specific branches. -
Normalized height via
normalizeSize— UsinggetScale()to normalizegetBoundingClientRect().heightbefore comparing against layout values addresses the core fractional mismatch bug. -
Good test coverage — Tests for both scroll directions with fractional positions, plus the grouped overflow Chromium regression test. Clear test descriptions.
Issues & Questions
-
normalizeSizeindirection —normalizeSize(SelectPopup.tsx:579-581) is only used in two places: thecurrentHeightcomputation and insidenormalizeRect. The function name doesn't convey much beyond whatsize / scale[axis]already says. Consider whether the helper is worth it vs. inlining. -
Early return changes guard behavior — The PR adds an early return when
!isTopPositioned && !isBottomPositionedinhandleScroll. Previously the code would fall through and still set height/scroll. This looks correct (aligned popups shouldn't resize), but it's a subtle behavioral change worth calling out. -
SCROLL_EDGE_TOLERANCE_PXin item boundary checks — IngetTargetScrollTop, the tolerance is applied tovisibleTopandvisibleBottom(SelectScrollArrow.tsx:633, 651), treating items within 1px of the visible edge as visible. This is the key fix for fractional boundaries where items that were almost visible would cause the scroll to stall. Looks correct. -
Removed
initialHeightRef/maxHeightRef— Replaced with a localinitialHeightvariable. Works because it's computed and used within the same synchronousonPlacedcallback. Correct simplification. -
Drive-by fix:
SelectScrollDownArrow.test.tsx— The existing file incorrectly referencedScrollUpArrowin describe/conformance names. Good catch. -
Chromium-only zoom test — The zoom test modifies
document.documentElement.style.zoom, properly guarded withskipIf(isJSDOM)and wrapped in try/finally. Fine.
Verdict
Clean, well-tested fix for a real fractional-pixel bug. The refactoring is justified — it reduces duplication and consolidates scroll edge logic. No correctness issues spotted.
Fixes #4444
This fixes the Select scroll arrows stopping short of the true start or end when constrained layouts leave the popup or item bounds at fractional scroll positions.
The issue is easiest to reproduce when the popup overflows on both sides, including with DevTools open or at non-default browser zoom, but the underlying bug is the fractional edge handling rather than zoom itself.
Changes
scrollEdgeshelper used by Select and Scroll Area.