From 27c15bfd53607883d4e0bdac1f7d3f54268e4fa2 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 14 Nov 2022 08:15:20 +0100 Subject: [PATCH] FIX: ensures composer is focused after edit (#18999) - afterRender is not needed as it's already done in the `chat:focus-composer` event - removes `focusComposer` function which is duplicating logic --- .../discourse/components/chat-live-pane.js | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.js b/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.js index c23974fa4e..54fd768d2d 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.js +++ b/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.js @@ -246,7 +246,7 @@ export default Component.extend({ this.highlightOrFetchMessage(this.targetMessageId); } - this.focusComposer(); + this._focusComposer(); }) .catch(this._handleErrors) .finally(() => { @@ -1165,6 +1165,7 @@ export default Component.extend({ } if (lastUserMessage) { this.set("editingMessage", lastUserMessage); + this._focusComposer(); } }, @@ -1395,21 +1396,6 @@ export default Component.extend({ return this._fetchAndScrollToLatest(); }, - focusComposer() { - if ( - this._selfDeleted || - this.site.mobileView || - this.chatChannel?.isDraft - ) { - return; - } - - schedule("afterRender", () => { - document.querySelector(".chat-composer-input")?.focus(); - }); - }, - - @afterRender _focusComposer() { this.appEvents.trigger("chat:focus-composer"); },