Notify the timeline it's height has changed, so it can keep being at the bottom

this way new messages will appear in the timeline without needing to scroll
This commit is contained in:
Bruno Windels 2020-07-31 14:02:40 +02:00
parent 01d624fdaf
commit d24ddc415b
4 changed files with 13 additions and 0 deletions

View file

@ -1912,6 +1912,7 @@ export default createReactClass({
disabled={this.props.disabled}
showApps={this.state.showApps}
e2eStatus={this.state.e2eStatus}
resizeNotifier={this.props.resizeNotifier}
permalinkCreator={this._getPermalinkCreatorForRoom(this.state.room)}
/>;
}

View file

@ -354,6 +354,7 @@ export default class MessageComposer extends React.Component {
key="controls_input"
room={this.props.room}
placeholder={this.renderPlaceholderText()}
resizeNotifier={this.props.resizeNotifier}
permalinkCreator={this.props.permalinkCreator} />,
<UploadButton key="controls_upload" roomId={this.props.room.roomId} />,
<EmojiButton key="emoji_button" addEmoji={this.addEmoji} />,

View file

@ -365,6 +365,13 @@ export default class SendMessageComposer extends React.Component {
onAction = (payload) => {
switch (payload.action) {
case 'reply_to_event':
// add a timeout for the reply preview to be rendered, so
// that the ScrollPanel listening to the resizeNotifier can
// correctly measure it's new height and scroll down to keep
// at the bottom if it already is
setTimeout(() => {
this.props.resizeNotifier.notifyTimelineHeightChanged();
}, 100);
case Action.FocusComposer:
this._editorRef && this._editorRef.focus();
break;

View file

@ -53,6 +53,10 @@ export default class ResizeNotifier extends EventEmitter {
this._updateMiddlePanel();
}
notifyTimelineHeightChanged() {
this._updateMiddlePanel();
}
// can be called in quick succession
notifyWindowResized() {
// no need to throttle this one,