diff --git a/packages/flat-components/src/components/ChatPanel/ChatMessageList/index.tsx b/packages/flat-components/src/components/ChatPanel/ChatMessageList/index.tsx index f893fc2f135..fefb4fdcaf9 100644 --- a/packages/flat-components/src/components/ChatPanel/ChatMessageList/index.tsx +++ b/packages/flat-components/src/components/ChatPanel/ChatMessageList/index.tsx @@ -90,8 +90,15 @@ export const ChatMessageList = /* @__PURE__ */ observer( latestMessage!.timestamp > prev.latestMessage.timestamp ) { // user sent a new message - // scroll to the bottom - setScrollToIndex(messageCount - 1); + // scroll to the bottom only if the user is the last message's sender or is at bottom + if (latestMessage?.senderID === userUUID) { + setScrollToIndex(messageCount - 1); + } else { + const div = document.querySelector(".chat-message-list"); + if (div && div.scrollTop + div.clientHeight >= div.scrollHeight - 30) { + setScrollToIndex(messageCount - 1); + } + } } else { // history messages loaded // stay at the last position @@ -157,7 +164,7 @@ export const ChatMessageList = /* @__PURE__ */ observer( {() => (