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(web): chat input auto resize by window (#2696)

Rhon Joec439952a41d6
diff --git a/web/app/components/base/chat/chat/index.tsx b/web/app/components/base/chat/chat/index.tsx
index 99032e61ed7..67a91e21506 100644
--- a/web/app/components/base/chat/chat/index.tsx
+++ b/web/app/components/base/chat/chat/index.tsx
@@ -9,6 +9,7 @@ import {
} from 'react'
import { useTranslation } from 'react-i18next'
import { useThrottleEffect } from 'ahooks'
+import { debounce } from 'lodash-es'
import type {
ChatConfig,
ChatItem,
@@ -81,16 +82,24 @@ const Chat: FC<ChatProps> = ({
chatContainerRef.current.scrollTop = chatContainerRef.current.scrollHeight
}
- useThrottleEffect(() => {
- handleScrolltoBottom()
-
+ const handleWindowResize = () => {
if (chatContainerRef.current && chatFooterRef.current)
chatFooterRef.current.style.width = `${chatContainerRef.current.clientWidth}px`
if (chatContainerInnerRef.current && chatFooterInnerRef.current)
chatFooterInnerRef.current.style.width = `${chatContainerInnerRef.current.clientWidth}px`
+ }
+
+ useThrottleEffect(() => {
+ handleScrolltoBottom()
+ handleWindowResize()
}, [chatList], { wait: 500 })
+ useEffect(() => {
+ window.addEventListener('resize', debounce(handleWindowResize))
+ return () => window.removeEventListener('resize', handleWindowResize)
+ }, [])
+
useEffect(() => {
if (chatFooterRef.current && chatContainerRef.current) {
const resizeObserver = new ResizeObserver((entries) => {