fix chat scroll behaviour

This commit is contained in:
2026-04-16 00:25:32 -06:00
parent 3c4ec5b11e
commit eb7d144b91
2 changed files with 6 additions and 16 deletions

View File

@@ -111,14 +111,9 @@ function AiChatPage() {
lastScrolledIdRef.current = lastMsg.id;
const area = messagesAreaRef.current;
if (!area) return;
const isOwn = lastMsg.senderId === user?.id;
if (isOwn) {
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
} else {
const nearBottom = area.scrollHeight - area.scrollTop - area.clientHeight < 150;
if (nearBottom) messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
}
}, [messages, user?.id]);
const nearBottom = area.scrollHeight - area.scrollTop - area.clientHeight < 150;
if (nearBottom) messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
}, [messages]);
useEffect(() => {
if (!botTyping) return;