Merge pull request #12354 from ramonlsouza/new-message-chat-scroll

fix: handle new message auto-scroll in chat
This commit is contained in:
Anton Georgiev 2021-05-11 18:40:04 -04:00 committed by GitHub
commit bd51a191bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -104,8 +104,19 @@ class TimeWindowList extends PureComponent {
syncedPercent,
lastTimeWindowValuesBuild,
scrollPosition: scrollProps,
count
} = this.props;
const { userScrolledBack } = this.state;
if((count > 0 && !userScrolledBack) || userSentMessage){
const lastItemIndex = timeWindowsValues.length - 1;
this.setState({
scrollPosition: lastItemIndex,
}, ()=> this.handleScrollUpdate(lastItemIndex));
}
const {
timeWindowsValues: prevTimeWindowsValues,
chatId: prevChatId,
@ -304,10 +315,11 @@ class TimeWindowList extends PureComponent {
const {
scrollArea,
scrollPosition,
userScrolledBack,
} = this.state;
ChatLogger.debug('TimeWindowList::render', {...this.props}, {...this.state}, new Date());
const shouldAutoScroll = !!(scrollPosition && timeWindowsValues.length >= scrollPosition);
const shouldAutoScroll = !!(scrollPosition && timeWindowsValues.length >= scrollPosition && !userScrolledBack);
return (
[<div