From 78616404cea94004ff585e91141bf77553205eb1 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Fri, 5 May 2023 13:14:13 +0200 Subject: [PATCH] UX: scroll to bottom when message is staged (#21408) Since our recent change of inverting thread scrolling direction it feels more responsive to scroll down in thread panel as soon as message is staged and not after it's actually persisted. --- .../assets/javascripts/discourse/components/chat-thread.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-thread.js b/plugins/chat/assets/javascripts/discourse/components/chat-thread.js index 2b5d6e6e74c..d0513a2326d 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-thread.js +++ b/plugins/chat/assets/javascripts/discourse/components/chat-thread.js @@ -190,6 +190,8 @@ export default class ChatThreadPanel extends Component { this.resetComposer(); this.thread.messagesManager.addMessages([stagedMessage]); + this.scrollToBottom(); + return this.chatApi .sendMessage(this.channel.id, { message: stagedMessage.message, @@ -199,9 +201,6 @@ export default class ChatThreadPanel extends Component { thread_id: this.thread.staged ? null : stagedMessage.thread.id, staged_thread_id: this.thread.staged ? stagedMessage.thread.id : null, }) - .then(() => { - this.scrollToBottom(); - }) .catch((error) => { this.#onSendError(stagedMessage.id, error); })