fix: scroll bottom when generation text (#4323)
* fix: scroll bottom when generation text * chore: update logic when prepare generate * chore: fix case no switch thread * chore: remore dep thread id * chore: handle fix generation without have dep thread id
This commit is contained in:
parent
df1c465fd9
commit
56d1ffa136
@ -85,24 +85,33 @@ const ChatBody = memo(
|
||||
overscan: 5,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (parentRef.current) {
|
||||
parentRef.current.scrollTo({ top: parentRef.current.scrollHeight })
|
||||
virtualizer.scrollToIndex(count - 1)
|
||||
}
|
||||
}, [count, virtualizer])
|
||||
|
||||
useEffect(() => {
|
||||
if (parentRef.current && isGeneratingResponse) {
|
||||
requestAnimationFrame(() => {
|
||||
if (parentRef.current) {
|
||||
parentRef.current.scrollTo({ top: parentRef.current.scrollHeight })
|
||||
}
|
||||
})
|
||||
parentRef.current.scrollTo({ top: parentRef.current.scrollHeight })
|
||||
virtualizer.scrollToIndex(count - 1)
|
||||
}
|
||||
}, [count, virtualizer, isGeneratingResponse])
|
||||
|
||||
useEffect(() => {
|
||||
if (parentRef.current && isGeneratingResponse) {
|
||||
parentRef.current.scrollTo({ top: parentRef.current.scrollHeight })
|
||||
virtualizer.scrollToIndex(count - 1)
|
||||
}
|
||||
}, [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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user