mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
More scrolling fixes (#6780)
* Added MarkdownImage component * Fixed unit tests * More scrolling fixes
This commit is contained in:
committed by
Christopher Speller
parent
84d5f314a0
commit
bf81fea9f8
@@ -4,6 +4,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
import {postListScrollChange} from 'actions/global_actions.jsx';
|
||||||
|
|
||||||
import * as Utils from 'utils/utils.jsx';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
import * as CommonUtils from 'utils/commons.jsx';
|
import * as CommonUtils from 'utils/commons.jsx';
|
||||||
|
|
||||||
@@ -82,6 +84,10 @@ export default class PostAttachmentOpenGraph extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate() {
|
||||||
|
postListScrollChange();
|
||||||
|
}
|
||||||
|
|
||||||
fetchData(url) {
|
fetchData(url) {
|
||||||
if (!this.props.openGraphData) {
|
if (!this.props.openGraphData) {
|
||||||
this.props.actions.getOpenGraphMetadata(url);
|
this.props.actions.getOpenGraphMetadata(url);
|
||||||
|
|||||||
@@ -174,9 +174,9 @@ export default class PostList extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps, prevState) {
|
||||||
// Do not update scrolling unless posts change
|
// Do not update scrolling unless posts, visibility or intro message change
|
||||||
if (this.props.posts === prevProps.posts) {
|
if (this.props.posts === prevProps.posts && this.props.postVisibility === prevProps.postVisibility && this.state.atEnd === prevState.atEnd) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ export default class PostList extends React.PureComponent {
|
|||||||
const element = ReactDOM.findDOMNode(focusedPost);
|
const element = ReactDOM.findDOMNode(focusedPost);
|
||||||
const rect = element.getBoundingClientRect();
|
const rect = element.getBoundingClientRect();
|
||||||
const listHeight = postList.clientHeight / 2;
|
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) {
|
} else if (this.previousScrollHeight !== postList.scrollHeight && posts[0].id === prevPosts[0].id) {
|
||||||
postList.scrollTop = this.previousScrollTop + (postList.scrollHeight - this.previousScrollHeight);
|
postList.scrollTop = this.previousScrollTop + (postList.scrollHeight - this.previousScrollHeight);
|
||||||
}
|
}
|
||||||
@@ -204,7 +204,7 @@ export default class PostList extends React.PureComponent {
|
|||||||
const element = ReactDOM.findDOMNode(messageSeparator);
|
const element = ReactDOM.findDOMNode(messageSeparator);
|
||||||
element.scrollIntoView();
|
element.scrollIntoView();
|
||||||
return;
|
return;
|
||||||
} else if (this.refs.postlist && !this.hasScrolledToNewMessageSeparator) {
|
} else if (postList && !this.hasScrolledToNewMessageSeparator) {
|
||||||
postList.scrollTop = postList.scrollHeight;
|
postList.scrollTop = postList.scrollHeight;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -356,7 +356,9 @@ export default class PostList extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
scrollToBottom = () => {
|
scrollToBottom = () => {
|
||||||
this.refs.postlist.scrollTop = this.refs.postlist.scrollHeight;
|
if (this.refs.postlist) {
|
||||||
|
this.refs.postlist.scrollTop = this.refs.postlist.scrollHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createPosts = (posts) => {
|
createPosts = (posts) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user