diff --git a/.gitignore b/.gitignore index 1759b24fb..bfe621f41 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,5 @@ next-env.d.ts #Notion_db /Notion_DB + +/.idea diff --git a/pages/index.tsx b/pages/index.tsx index c80830751..75663e993 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -41,6 +41,10 @@ export default function Home() { textAreaRef.current?.focus(); }, []); + useEffect(() => { + messageListRef.current?.scrollTo(0, messageListRef.current.scrollHeight); + }, [messages]); + //handle form submission async function handleSubmit(e: any) { e.preventDefault(); @@ -102,8 +106,6 @@ export default function Home() { setLoading(false); - //scroll to bottom - messageListRef.current?.scrollTo(0, messageListRef.current.scrollHeight); } catch (error) { setLoading(false); setError('An error occurred while fetching the data. Please try again.');