Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: chat scroll (#2981)

zxhlyh61f5de966236
diff --git a/web/app/components/base/chat/chat/index.tsx b/web/app/components/base/chat/chat/index.tsx
index 2e46f1e8697..1b8ef36d051 100644
--- a/web/app/components/base/chat/chat/index.tsx
+++ b/web/app/components/base/chat/chat/index.tsx
@@ -9,7 +9,6 @@ import {
useRef,
} from 'react'
import { useTranslation } from 'react-i18next'
-import { useThrottleEffect } from 'ahooks'
import { debounce } from 'lodash-es'
import type {
ChatConfig,
@@ -92,10 +91,19 @@ const Chat: FC<ChatProps> = ({
chatFooterInnerRef.current.style.width = `${chatContainerInnerRef.current.clientWidth}px`
}, [])
- useThrottleEffect(() => {
+ useEffect(() => {
handleScrolltoBottom()
handleWindowResize()
- }, [chatList], { wait: 500 })
+ }, [handleScrolltoBottom, handleWindowResize])
+
+ useEffect(() => {
+ if (chatContainerRef.current) {
+ requestAnimationFrame(() => {
+ handleScrolltoBottom()
+ handleWindowResize()
+ })
+ }
+ })
useEffect(() => {
window.addEventListener('resize', debounce(handleWindowResize))