From d33d781264b9579a9338e67d59f387c4d6399c4c Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sun, 5 Dec 2021 22:11:04 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=BB=9A=E5=8A=A8=E5=88=B0=E5=BA=95=E9=83=A8=E7=9A=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChatBox/ChatMessageList/VirtualizedList.new.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/web/src/components/ChatBox/ChatMessageList/VirtualizedList.new.tsx b/web/src/components/ChatBox/ChatMessageList/VirtualizedList.new.tsx index bcfd09c4..a04bad4f 100644 --- a/web/src/components/ChatBox/ChatMessageList/VirtualizedList.new.tsx +++ b/web/src/components/ChatBox/ChatMessageList/VirtualizedList.new.tsx @@ -43,11 +43,13 @@ export const VirtualizedMessageList: React.FC = React.memo( } setTimeout(() => { - // 这里 Virtuoso 有个动态渲染高度的bug, 因此需要异步再次滚动到底部 - listRef.current?.scrollToIndex( - PREPEND_OFFSET - numItemsPrepended + props.messages.length - 1 - ); - }, 100); + // 这里 Virtuoso 有个动态渲染高度的bug, 因此需要异步再次滚动到底部以确保代码功能work + listRef.current?.scrollToIndex({ + index: + PREPEND_OFFSET - numItemsPrepended + props.messages.length - 1, + align: 'end', + }); + }, 20); } /**