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} disabled={this.props.disabled}
showApps={this.state.showApps} showApps={this.state.showApps}
e2eStatus={this.state.e2eStatus} e2eStatus={this.state.e2eStatus}
resizeNotifier={this.props.resizeNotifier}
permalinkCreator={this._getPermalinkCreatorForRoom(this.state.room)} permalinkCreator={this._getPermalinkCreatorForRoom(this.state.room)}
/>; />;
} }

View file

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

View file

@ -365,6 +365,13 @@ export default class SendMessageComposer extends React.Component {
onAction = (payload) => { onAction = (payload) => {
switch (payload.action) { switch (payload.action) {
case 'reply_to_event': 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: case Action.FocusComposer:
this._editorRef && this._editorRef.focus(); this._editorRef && this._editorRef.focus();
break; break;

View file

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