From 9a2c4fe3b68a4165acbaa35645e93a7eb820e83f Mon Sep 17 00:00:00 2001 From: sjiampojamarn <18257803+sjiampojamarn@users.noreply.github.com> Date: Sun, 16 Mar 2025 09:23:22 -0700 Subject: [PATCH] Only set scrollIntoView for user msg. --- ui/components/Chat.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/components/Chat.tsx b/ui/components/Chat.tsx index 81aa32f..0cf125b 100644 --- a/ui/components/Chat.tsx +++ b/ui/components/Chat.tsx @@ -48,11 +48,17 @@ const Chat = ({ }); useEffect(() => { - messageEnd.current?.scrollIntoView({ behavior: 'smooth' }); + const scroll = () => { + messageEnd.current?.scrollIntoView({ behavior: 'smooth' }); + }; if (messages.length === 1) { document.title = `${messages[0].content.substring(0, 30)} - Perplexica`; } + + if (messages[messages.length - 1]?.role == 'user') { + scroll(); + } }, [messages]); return (