From caf77adcd954d6d3066a51d9a03bcb62c0fccc1d Mon Sep 17 00:00:00 2001 From: waleed Date: Mon, 15 Jun 2026 23:36:19 -0700 Subject: [PATCH] fix(chat): align scrollbar/keyboard detach with wheel/touch re-engage threshold The onScroll detach branch set only stickyRef.current = false, leaving userDetachedRef false, so a scrollbar-drag or keyboard detach kept the lenient 30px (STICK_THRESHOLD) re-engage threshold instead of the strict 5px (REATTACH_THRESHOLD) used after wheel/touch. A programmatic virtualizer re-pin landing within 30px could then snap autoscroll back on right after the user deliberately scrolled away. Reuse the detach() helper so all detach paths set userDetachedRef consistently. --- apps/sim/hooks/use-auto-scroll.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/sim/hooks/use-auto-scroll.ts b/apps/sim/hooks/use-auto-scroll.ts index efe44b313f..f76b754750 100644 --- a/apps/sim/hooks/use-auto-scroll.ts +++ b/apps/sim/hooks/use-auto-scroll.ts @@ -147,7 +147,7 @@ export function useAutoScroll( scrollTop < prevScrollTopRef.current && scrollHeight <= prevScrollHeightRef.current ) { - stickyRef.current = false + detach() } prevScrollTopRef.current = scrollTop