fix: enhance autoscroll logic to consider messages and suggested questions

This commit is contained in:
zaidmukaddam 2024-12-18 20:46:36 +05:30
parent 83c0805074
commit 32f0b17597

View File

@ -2033,7 +2033,7 @@ The new Anthropic models: Claude 3.5 Sonnet and 3.5 Haiku models are now availab
useEffect(() => { useEffect(() => {
const handleScroll = () => { const handleScroll = () => {
const userScrolled = window.innerHeight + window.scrollY < document.body.offsetHeight; const userScrolled = window.innerHeight + window.scrollY < document.body.offsetHeight;
if (!userScrolled && bottomRef.current) { if (!userScrolled && bottomRef.current && (messages.length > 0 || suggestedQuestions.length > 0)) {
bottomRef.current.scrollIntoView({ behavior: "smooth" }); bottomRef.current.scrollIntoView({ behavior: "smooth" });
} }
}; };