Message List: Fix losing scroll position in unread chats (follow-up)

This commit is contained in:
Alexander Zinchuk 2021-06-29 19:35:49 +03:00
parent bb75af6dcd
commit 95cfce6927

View File

@ -471,8 +471,11 @@ const MessageList: FC<OwnProps & StateProps & DispatchProps> = ({
} else if (anchor) {
const newAnchorTop = anchor.getBoundingClientRect().top;
newScrollTop = scrollTop + (newAnchorTop - (anchorTopRef.current || 0));
} else if (unreadDivider && !scrollOffset) {
newScrollTop = unreadDivider.offsetTop - (hasTools ? UNREAD_DIVIDER_TOP_WITH_TOOLS : UNREAD_DIVIDER_TOP);
} else if (unreadDivider) {
newScrollTop = Math.min(
unreadDivider.offsetTop - (hasTools ? UNREAD_DIVIDER_TOP_WITH_TOOLS : UNREAD_DIVIDER_TOP),
scrollHeight - scrollOffset,
);
} else {
newScrollTop = scrollHeight - scrollOffset;
}