A platform for community discussion. Free, open, simple.
FIX: correctly differentiates channel/thread upload inputs (#21301)
Joffrey JAFFEUX290bd975c540
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-composer-uploads.js b/plugins/chat/assets/javascripts/discourse/components/chat-composer-uploads.jsindex 6ecd680cbb0..9371e9632a4 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-composer-uploads.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat-composer-uploads.js@@ -39,7 +39,7 @@ export default Component.extend(UppyUploadMixin, {didInsertElement() {this._super(...arguments);- this.composerInputEl = document.querySelector(".chat-composer__input");+this.composerInputEl?.addEventListener("paste", this._pasteEventListener);},diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbsindex fbb555f026e..01e41b2fb69 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbs@@ -42,6 +42,7 @@<div class="chat-composer__input-container"><DTextarea+ id={{this.composerId}}value={{readonly this.currentMessage.message}}type="text"class="chat-composer__input"@@ -86,6 +87,7 @@@onUploadChanged={{this.onUploadChanged}}@existingUploads={{this.currentMessage.uploads}}@uploadDropZone={{@uploadDropZone}}+ @composerInputEl={{this.textareaInteractor.textarea}}/>{{/if}}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/composer/channel.js b/plugins/chat/assets/javascripts/discourse/components/chat/composer/channel.jsindex 5f5e66e38d7..1116a0155cb 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat/composer/channel.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat/composer/channel.js@@ -12,6 +12,8 @@ export default class ChatComposerChannel extends ChatComposer {context = "channel";+ composerId = "channel-composer";+@actionsendMessage(raw) {const message = ChatMessage.createDraftMessage(this.args.channel, {diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/composer/thread.js b/plugins/chat/assets/javascripts/discourse/components/chat/composer/thread.jsindex 76a6c15860c..ea46f97046b 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat/composer/thread.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat/composer/thread.js@@ -11,6 +11,8 @@ export default class ChatComposerThread extends ChatComposer {context = "thread";+ composerId = "thread-composer";+@actionsendMessage(raw) {const message = ChatMessage.createDraftMessage(this.args.channel, {diff --git a/plugins/chat/assets/javascripts/discourse/lib/textarea-interactor.js b/plugins/chat/assets/javascripts/discourse/lib/textarea-interactor.jsindex d10eb0c5504..87417f28ce9 100644--- a/plugins/chat/assets/javascripts/discourse/lib/textarea-interactor.js+++ b/plugins/chat/assets/javascripts/discourse/lib/textarea-interactor.js@@ -22,7 +22,7 @@ export default class TextareaInteractor extends EmberObject.extend(this._textarea = textarea;this.element = this._textarea;this.ready = true;- this.composerFocusSelector = ".chat-composer__input";+ this.composerFocusSelector = `#${textarea.id}`;this.init(); // mixin init wouldn't be called otherwisethis.composerEventPrefix = null; // we don't need app eventsdiff --git a/plugins/chat/assets/stylesheets/common/chat-thread.scss b/plugins/chat/assets/stylesheets/common/chat-thread.scssindex d124fbd8ad4..a3dbdcf780d 100644--- a/plugins/chat/assets/stylesheets/common/chat-thread.scss+++ b/plugins/chat/assets/stylesheets/common/chat-thread.scss@@ -29,7 +29,7 @@will-change: transform;}- .chat-composer {+ .chat-composer__wrapper {padding-bottom: 28px;}}