From 8c1f13378b8d02e7c3305778e603b92f10639c2a Mon Sep 17 00:00:00 2001 From: Faisal Amir Date: Mon, 23 Dec 2024 16:04:48 +0700 Subject: [PATCH] fix: scroll bottom when generation text --- .../ThreadCenterPanel/ChatBody/index.tsx | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/web/screens/Thread/ThreadCenterPanel/ChatBody/index.tsx b/web/screens/Thread/ThreadCenterPanel/ChatBody/index.tsx index 29595f2491..9d7514123b 100644 --- a/web/screens/Thread/ThreadCenterPanel/ChatBody/index.tsx +++ b/web/screens/Thread/ThreadCenterPanel/ChatBody/index.tsx @@ -87,22 +87,16 @@ const ChatBody = memo( useEffect(() => { if (parentRef.current && isGeneratingResponse) { - requestAnimationFrame(() => { - if (parentRef.current) { - parentRef.current.scrollTo({ top: parentRef.current.scrollHeight }) - } - }) + parentRef.current.scrollTo({ top: parentRef.current.scrollHeight }) } - }, [count, virtualizer, isGeneratingResponse]) + }, [count, virtualizer, isGeneratingResponse, currentThread?.id]) useEffect(() => { isUserManuallyScrollingUp.current = false - requestAnimationFrame(() => { - if (parentRef.current) { - parentRef.current.scrollTo({ top: parentRef.current.scrollHeight }) - virtualizer.scrollToIndex(count - 1) - } - }) + if (parentRef.current) { + parentRef.current.scrollTo({ top: parentRef.current.scrollHeight }) + virtualizer.scrollToIndex(count - 1) + } }, [count, currentThread?.id, virtualizer]) const items = virtualizer.getVirtualItems()