Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/modules/Channel/components/Message/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,12 @@ const Message = ({
}));
}, [mentionedUserIds]);

// Move the messsage list scroll when the last message's height is changed by reactions
/**
* Move the messsage list scroll
* when the message's height is changed by `showEdit` OR `message.reactions`
*/
useDidMountEffect(() => {
if (currentGroupChannel?.lastMessage?.messageId === message?.messageId) {
handleScroll?.();
}
handleScroll?.();
}, [showEdit, message?.reactions?.length]);
useLayoutEffect(() => {
handleMessageListHeightChange?.();
Expand Down
8 changes: 6 additions & 2 deletions src/modules/Channel/components/MessageList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,16 @@ const MessageList: React.FC<MessageListProps> = ({
}
};

// Move the messsage list scroll when the last message's height is changed by reactions
/**
* Move the messsage list scroll
* when each message's height is changed by `reactions` OR `showEdit`
*/
const handleMessageHeightChange = () => {
const current = scrollRef?.current;
if (current) {
const bottom = current.scrollHeight - current.scrollTop - current.offsetHeight;
if (scrollBottom < bottom && scrollBottom <= SCROLL_BUFFER) {
if (scrollBottom < bottom) {
// Move the scroll as much as the height of the message has changed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

current.scrollTop += bottom - scrollBottom;
}
}
Expand Down