Fix: guard onMessagesWheel against non-scrollable containers

The wheel handler unconditionally set shouldAutoScrollRef to false on
upward wheel events, even when the scroll container had no overflow.
Since no scroll event fires in that case, auto-scroll stayed permanently
disabled. Add a scrollHeight > clientHeight guard so the handler only
disables auto-scroll when the container actually has scrollable content.
This commit is contained in:
Cursor Agent committed 2026-02-20 00:12:50 +00:00
1 parent 0cb4e75728
commit 082ec99238
1 file changed
+4 -1
+4 -1
View File
@@ -1140,7 +1140,10 @@ export default function ChatView({ threadId }: ChatViewProps) {
}, []);
const onMessagesWheel = useCallback((event: WheelEvent<HTMLDivElement>) => {
if (event.deltaY < 0) {
shouldAutoScrollRef.current = false;
const el = messagesScrollRef.current;
if (el && el.scrollHeight > el.clientHeight) {
shouldAutoScrollRef.current = false;
}
}
}, []);
useLayoutEffect(() => {