From ba64aec5b0e395afc5071d3d7d33baaf082f23a5 Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Wed, 8 Jan 2025 22:49:52 +0800 Subject: [PATCH] scroll to bottom at message sent --- src/pages/Chatbox.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pages/Chatbox.tsx b/src/pages/Chatbox.tsx index b6c3544..9a4bb29 100644 --- a/src/pages/Chatbox.tsx +++ b/src/pages/Chatbox.tsx @@ -347,6 +347,10 @@ export default function ChatBOX() { // when user click the "send" button or ctrl+Enter in the textarea const send = async (msg = "", call_complete = true) => { + if (messagesEndRef.current) { + messagesEndRef.current.scrollIntoView({ behavior: "smooth" }); + } + const inputMsg = msg.trim(); if (!inputMsg && images.length === 0) { console.log("empty message");