From 2d7ae2170dbaa56b8acde1ee833ddaf9eb653017 Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Wed, 7 Feb 2024 15:46:00 +0700 Subject: [PATCH] Simplify [UI/UX] [Chat] [Front End] scrollDomToBottom - [+] refactor(chat.tsx): improve smooth scrolling behavior in useScrollToBottom function --- app/components/chat.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 39abdd97b24..f7282b75fbb 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -383,10 +383,8 @@ function useScrollToBottom() { function scrollDomToBottom() { const dom = scrollRef.current; if (dom) { - requestAnimationFrame(() => { - setAutoScroll(true); - dom.scrollTo(0, dom.scrollHeight); - }); + // Improve Use smooth scrolling behavior + dom.scrollTo({ top: dom.scrollHeight, behavior: 'smooth' }); } }