Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
[MM-30340] Update post height when comment box height change occurs (#…
Browse files Browse the repository at this point in the history
…7039) (#7044)

Automatic Merge
  • Loading branch information
mattermost-build authored Nov 9, 2020
1 parent e1ee205 commit 8a75a46
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions components/create_comment/create_comment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ class CreateComment extends React.PureComponent {
getChannelMemberCountsByGroup: PropTypes.func.isRequired,
groupsWithAllowReference: PropTypes.object,
channelMemberCountsByGroup: PropTypes.object,
onHeightChange: PropTypes.func,
}

static getDerivedStateFromProps(props, state) {
Expand Down Expand Up @@ -971,6 +972,10 @@ class CreateComment extends React.PureComponent {
this.setState({scrollbarWidth: Utils.scrollbarWidth(this.refs.textbox.getInputBox())});
}
});

if (this.props.onHeightChange) {
this.props.onHeightChange();
}
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ exports[`components/RhsThread should match snapshot 1`] = `
<Connect(injectIntl(CreateComment))
channelId="channel_id"
latestPostId="id"
onHeightChange={[Function]}
rootDeleted={false}
rootId="id"
/>
Expand Down
10 changes: 6 additions & 4 deletions components/rhs_thread/rhs_thread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,6 @@ export default class RhsThread extends React.Component<Props, State> {
this.props.actions.selectPostCard(post);
}

private onBusy = (isBusy: boolean) => {
this.setState({isBusy});
}

private filterPosts = (posts: Post[], selected: Post | FakePost, openTime: number): Post[] => {
const postsArray: Post[] = [];

Expand Down Expand Up @@ -297,6 +293,11 @@ export default class RhsThread extends React.Component<Props, State> {
});
}

private handlePostCommentResize = (): void => {
this.resizeRhsPostList();
this.scrollToBottom();
}

public render(): JSX.Element {
if (this.props.posts == null || this.props.selected == null || !this.props.channel) {
return (
Expand Down Expand Up @@ -381,6 +382,7 @@ export default class RhsThread extends React.Component<Props, State> {
ref={this.postCreateContainerRef}
>
<CreateComment
onHeightChange={this.handlePostCommentResize}
channelId={selected.channel_id}
rootId={selected.id}
rootDeleted={(selected as Post).state === Posts.POST_DELETED}
Expand Down

0 comments on commit 8a75a46

Please sign in to comment.