From 313a0e579e602208f6311bd367ad4a5c2b3d6da7 Mon Sep 17 00:00:00 2001 From: Shantur Rathore Date: Fri, 17 Apr 2026 15:20:48 +0100 Subject: [PATCH] fix(ui): hold streaming replies once top leaves view --- packages/ui/src/components/virtual-follow-list.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/ui/src/components/virtual-follow-list.tsx b/packages/ui/src/components/virtual-follow-list.tsx index bfc3558a..0c0bbe35 100644 --- a/packages/ui/src/components/virtual-follow-list.tsx +++ b/packages/ui/src/components/virtual-follow-list.tsx @@ -3,7 +3,6 @@ import { Virtualizer, type VirtualizerHandle } from "virtua/solid" const DEFAULT_SCROLL_SENTINEL_MARGIN_PX = 48 const DEFAULT_HOLD_TARGET_TOP_THRESHOLD_PX = 8 -const DEFAULT_HOLD_TARGET_TOP_OVERSHOOT_PX = 128 const USER_SCROLL_INTENT_WINDOW_MS = 600 const SCROLL_INTENT_KEYS = new Set(["ArrowUp", "ArrowDown", "PageUp", "PageDown", "Home", "End", " ", "Spacebar"]) @@ -375,11 +374,11 @@ export default function VirtualFollowList(props: VirtualFollowListProps) { const relativeTop = targetRect.top - containerRect.top const exceedsViewport = targetRect.height > element.clientHeight - if ( - exceedsViewport && - relativeTop <= holdTargetTopThresholdPx() && - relativeTop >= holdTargetTopThresholdPx() - DEFAULT_HOLD_TARGET_TOP_OVERSHOOT_PX - ) { + if (exceedsViewport && relativeTop < 0) { + const alignDelta = relativeTop - holdTargetTopThresholdPx() + if (Math.abs(alignDelta) > 1) { + element.scrollTop = Math.max(0, element.scrollTop + alignDelta) + } setHeldItemCount(itemCount) } }