Merge pull request #18 from waleedlatif1/main

Modified autoscroll in response to only scroll if the user does not manually scroll up
This commit is contained in:
Zaid Mukaddam 2024-12-17 09:49:10 +05:30 committed by GitHub
commit 8600e1798d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2031,9 +2031,15 @@ The new Anthropic models: Claude 3.5 Sonnet and 3.5 Haiku models are now availab
}, [messages]);
useEffect(() => {
if (bottomRef.current) {
const handleScroll = () => {
const userScrolled = window.innerHeight + window.scrollY < document.body.offsetHeight;
if (!userScrolled && bottomRef.current) {
bottomRef.current.scrollIntoView({ behavior: "smooth" });
}
};
window.addEventListener('scroll', handleScroll);
return () => window.removeEventListener('scroll', handleScroll);
}, [messages, suggestedQuestions]);
const handleExampleClick = async (card: typeof suggestionCards[number]) => {