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:
1 parent
0cb4e75728
commit
082ec99238
1 file changed
+4
-1
@@ -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(() => {
|
||||
|
||||
Reference in new issue
Block a user