From 5682688aedc5088385220c13d4b3812ac1a8f7a1 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 11 Sep 2020 22:44:09 -0500 Subject: [PATCH] Chats: fix #418 scrolling resize issue --- app/soapbox/features/chats/components/chat_message_list.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/soapbox/features/chats/components/chat_message_list.js b/app/soapbox/features/chats/components/chat_message_list.js index 1cfc41442..bd20ffade 100644 --- a/app/soapbox/features/chats/components/chat_message_list.js +++ b/app/soapbox/features/chats/components/chat_message_list.js @@ -89,11 +89,16 @@ class ChatMessageList extends ImmutablePureComponent { return scrollBottom < elem.offsetHeight * 1.5; } + handleResize = (e) => { + if (this.isNearBottom()) this.scrollToBottom(); + } + componentDidMount() { const { dispatch, chatId } = this.props; dispatch(fetchChatMessages(chatId)); this.node.addEventListener('scroll', this.handleScroll); + window.addEventListener('resize', this.handleResize); this.scrollToBottom(); } @@ -125,6 +130,7 @@ class ChatMessageList extends ImmutablePureComponent { componentWillUnmount() { this.node.removeEventListener('scroll', this.handleScroll); + window.removeEventListener('resize', this.handleResize); } handleLoadMore = () => {