Skip to content

Commit

Permalink
feat(message list): added autoScrollToBottomOnMount property
Browse files Browse the repository at this point in the history
  • Loading branch information
supersnager committed Mar 24, 2021
1 parent acd4151 commit 6ba92a8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/MessageList/MessageList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ class MessageListInner extends React.Component {

componentDidMount() {
// Set scrollbar to bottom on start (getSnaphotBeforeUpdate is not invoked on mount)
this.scrollToEnd(this.props.scrollBehavior);
if (this.props.autoScrollToBottomOnMount === true) {
this.scrollToEnd(this.props.scrollBehavior);
}

this.lastClientHeight = this.containerRef.current.clientHeight;

Expand Down Expand Up @@ -252,6 +254,7 @@ class MessageListInner extends React.Component {
className,
scrollBehavior, // Just to remove rest
autoScrollToBottom, // Just to remove rest
autoScrollToBottomOnMount, // Just to remove rest
...rest
},
} = this;
Expand Down Expand Up @@ -371,6 +374,11 @@ MessageList.propTypes = {
*/
autoScrollToBottom: PropTypes.bool,

/**
* Auto scroll to bottom on mount
*/
autoScrollToBottomOnMount: PropTypes.bool,

/**
* Scroll behavior
* https://developer.mozilla.org/en-US/docs/Web/API/ScrollToOptions/behavior
Expand All @@ -387,6 +395,7 @@ MessageList.defaultProps = {
loadingMore: false,
loadingMorePosition: "top",
autoScrollToBottom: true,
autoScrollToBottomOnMount: true,
scrollBehavior: "auto",
};

Expand Down

0 comments on commit 6ba92a8

Please sign in to comment.