diff options
Diffstat (limited to 'webapp/components/post_view/post_list.jsx')
-rw-r--r-- | webapp/components/post_view/post_list.jsx | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/webapp/components/post_view/post_list.jsx b/webapp/components/post_view/post_list.jsx index b630a7d6a..ee0fcb99b 100644 --- a/webapp/components/post_view/post_list.jsx +++ b/webapp/components/post_view/post_list.jsx @@ -174,9 +174,9 @@ export default class PostList extends React.PureComponent { } } - componentDidUpdate(prevProps) { - // Do not update scrolling unless posts change - if (this.props.posts === prevProps.posts) { + componentDidUpdate(prevProps, prevState) { + // Do not update scrolling unless posts, visibility or intro message change + if (this.props.posts === prevProps.posts && this.props.postVisibility === prevProps.postVisibility && this.state.atEnd === prevState.atEnd) { return; } @@ -191,7 +191,7 @@ export default class PostList extends React.PureComponent { const element = ReactDOM.findDOMNode(focusedPost); const rect = element.getBoundingClientRect(); const listHeight = postList.clientHeight / 2; - postList.scrollTop += postList.scrollTop + (rect.top - listHeight); + postList.scrollTop += rect.top - listHeight; } else if (this.previousScrollHeight !== postList.scrollHeight && posts[0].id === prevPosts[0].id) { postList.scrollTop = this.previousScrollTop + (postList.scrollHeight - this.previousScrollHeight); } @@ -204,7 +204,7 @@ export default class PostList extends React.PureComponent { const element = ReactDOM.findDOMNode(messageSeparator); element.scrollIntoView(); return; - } else if (this.refs.postlist && !this.hasScrolledToNewMessageSeparator) { + } else if (postList && !this.hasScrolledToNewMessageSeparator) { postList.scrollTop = postList.scrollHeight; return; } @@ -356,7 +356,9 @@ export default class PostList extends React.PureComponent { } scrollToBottom = () => { - this.refs.postlist.scrollTop = this.refs.postlist.scrollHeight; + if (this.refs.postlist) { + this.refs.postlist.scrollTop = this.refs.postlist.scrollHeight; + } } createPosts = (posts) => { |