fix(ui): stop scroll bounce when collapsing chrome pins at the bottom#828
Conversation
The phone hide-on-scroll chrome (header/composer) collapses in-flow, so hiding it grows the scroll container and shrinks its max scroll offset. At the bottom the browser clamps scrollTop to that shrinking maximum, emitting a phantom "up" reading each frame of the collapse animation. The previous bottom-clamp guard only held the hidden state when the prior offset sat more than `minimumDelta` above the new maximum — a predicate the browser's per-frame clamping makes unreliable — so on the frames it missed the phantom "up" revealed the chrome, which grew the viewport back and started a hide/reveal bounce (the choppiness and bounce felt when scrolling to the bottom). Generalise the guard to the robust invariant: while the chrome is hidden and the offset stays pinned to the bottom edge, any upward reading is layout feedback, not a scroll — hold the hidden state and rebase intent. Only a genuine upward scroll (one that pulls the offset clear of the bottom) reveals. This holds across the whole multi-frame collapse without depending on the previous offset, so the bottom stays stable and all content remains reachable. Add deterministic unit tests for the multi-frame collapse clamp and the small-shrink phantom the old predicate let slip through. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E4Fomoa1oeD6nqf8QNNytj
|
Warning Review limit reached
Next review available in: 24 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughUpdates scroll-hide behavior to recognize near-bottom upward offsets as layout clamping, preserving hidden chrome during collapse and revealing it after a genuine upward scroll. Adds tests for multi-frame and single-frame clamp scenarios. ChangesScroll clamp handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Collapse the bottom-clamp guard condition onto one line to match the repository's Prettier print width; the CI format:check gate flagged it. No logic change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E4Fomoa1oeD6nqf8QNNytj
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/clinical-dashboard/use-hide-on-scroll.ts`:
- Around line 72-86: Update the bottom-clamp condition in the currentlyHidden
scroll-handling branch so it treats an offset as pinned only when its distance
from maxOffset is within bottomClampTolerance on either side, rather than
accepting every offset above maxOffset minus the tolerance. Preserve the
hidden-state rebasing behavior for genuinely bottom-adjacent offsets.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 3c71badc-2c93-43f9-9da8-43e7853d5814
📒 Files selected for processing (2)
src/components/clinical-dashboard/use-hide-on-scroll.tstests/use-hide-on-scroll.test.ts
A review suggested making the bottom-edge tolerance symmetric (`|offset - maxOffset| <= tol`). That would regress iOS bottom rubber-band: during overscroll the browser reports a scrollTop past the maximum, and as the content springs back the reading moves up — still the bottom edge, not a scroll away from it. A symmetric window would fall through and reveal the chrome mid-rubber-band, reintroducing the flicker this guard removes. The one-sided test mirrors the existing `offset < 0` guard that holds state through top overscroll. Document the intent on the guard and add a regression test covering the bottom-overscroll spring-back so the asymmetry is not "fixed" later. No behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E4Fomoa1oeD6nqf8QNNytj
Summary
#main-contentscroll container. Hiding it grows the container and shrinks its max scroll offset (~72px). At the bottom the browser clampsscrollTopto that shrinking maximum, emitting a phantom "up" reading on each frame of the ~240ms collapse animation.computeScrollHideUpdateonly held the hidden state when the prior offset sat more thanminimumDeltaabove the new maximum — a predicate the browser's per-frame clamping makes unreliable. On the frames it missed, the phantom "up" revealed the chrome, which grew the viewport back and re-hid on the next down-scroll → a self-sustaining hide/reveal bounce.src/components/clinical-dashboard/use-hide-on-scroll.ts(generalised bottom-clamp guard +bottomClampTolerance),tests/use-hide-on-scroll.test.ts(deterministic multi-frame-collapse and bottom-overscroll tests).Verification
vitest run tests/use-hide-on-scroll.test.ts— 12 passed (9 existing + 3 new: multi-frame collapse clamp, small-shrink phantom, bottom rubber-band overscroll).ui-smokehide-on-scroll / header / dock / composer Playwright specs against the running dev server with the preinstalled Chromium — 10 passed, includingnon-answer phone header keeps the in-flow collapse hide,phone long answer stays scrollable and clear of the composer dock, andanswer glass header overlays main and fully hides while scrolling on phones..dom.test.tsxthat needsjsdom(missing in this container), unrelated to this change. Lint clean; no new typecheck errors (pre-existing test-dep errors unchanged: 51 before and after).scrollToplocked at the bottom); the last content element is fully visible (0px overflow).npm run verify:pr-local— this container is missing dev test deps (jsdom,@testing-library/react,@axe-core/playwright) and the managed Playwright browser build, so the packaged gate cannot run end-to-end here; the equivalent checks were run directly (above).npm run verify:uigate — same managed-Chromium gap; substituted with the equivalentui-smokeChromium specs above (10 passed).Risk and rollout
computeScrollHideUpdate) shared by all hide-on-scroll hosts, fully covered by unit tests and consistent with the existing bottom-clamp test.use-hide-on-scroll.ts; no data, schema, migration, or configuration change is involved.Clinical Governance Preflight
This is a client-side scroll-interaction fix, flagged clinical-risk only because the file path is under
src/components/clinical-dashboard/(the policy's path heuristic). It does not touch ingestion, answer generation, search/ranking, source rendering, document access, privacy, Supabase, or clinical output, so each item below holds unchanged.Clinical KB Database(sjrfecxgysukkwxsowpy)Notes
Generated by Claude Code