A platform for community discussion. Free, open, simple.
FIX: cancel editing should clear the composer (#21011)
Joffrey JAFFEUX79cacba9487b
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbsindex 95325f10fcf..57a44790854 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbs@@ -10,7 +10,7 @@<ChatComposerMessageDetails@message={{this.composerService.editingMessage}}@icon="pencil-alt"- @action={{action "cancelEditing"}}+ @action={{this.cancelEditing}}/>{{/if}}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-composer.js b/plugins/chat/assets/javascripts/discourse/components/chat-composer.jsindex 25e27a15a03..4bce7b50170 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-composer.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat-composer.js@@ -191,14 +191,12 @@ export default Component.extend(TextareaTextManipulation, {this.paneService?.editLastMessageRequested();}- if (event.keyCode === 27) {- // keyCode for 'Escape'+ if (event.key === "Escape") {if (this.composerService?.replyToMsg) {this.set("value", "");this.composerService?.setReplyTo(null);return false;} else if (this.composerService?.editingMessage) {- this.set("value", "");this.cancelEditing();return false;} else {@@ -719,6 +717,7 @@ export default Component.extend(TextareaTextManipulation, {@actioncancelEditing() {this.composerService?.cancelEditing();+ this.set("value", "");this._focusTextArea({ ensureAtEnd: true, resizeTextarea: true });},diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.hbsindex 8e3e8b912e4..0ad94728c19 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.hbs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-live-pane.hbs@@ -79,7 +79,6 @@{{#if (or @channel.isDraft @channel.isFollowing)}}<ChatComposer@sendMessage={{this.sendMessage}}- @onCancelEditing={{this.cancelEditing}}@chatChannel={{@channel}}@composerService={{this.chatChannelComposer}}@paneService={{this.chatChannelPane}}diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-thread.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-thread.hbsindex 9be768b82c6..a2e29d499ad 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-thread.hbs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-thread.hbs@@ -49,7 +49,6 @@{{else}}<ChatComposer@sendMessage={{this.sendMessage}}- @onCancelEditing={{this.cancelEditing}}@chatChannel={{this.channel}}@composerService={{this.chatChannelThreadComposer}}@paneService={{this.chatChannelThreadPane}}diff --git a/plugins/chat/spec/system/chat_composer_spec.rb b/plugins/chat/spec/system/chat_composer_spec.rbindex 572770996d2..132f1b3dae6 100644--- a/plugins/chat/spec/system/chat_composer_spec.rb+++ b/plugins/chat/spec/system/chat_composer_spec.rb@@ -72,6 +72,18 @@ RSpec.describe "Chat composer", type: :system, js: true dofind(".chat-composer-input").send_keys(:escape)expect(page).to have_no_selector(".chat-composer-message-details .chat-reply__username")+ expect(find(".chat-composer-input").value).to eq("")+ end+ end++ context "when closing edited message" do+ it "cancels editing" do+ chat.visit_channel(channel_1)+ channel.edit_message(message_2)+ find(".cancel-message-action").click++ expect(page).to have_no_selector(".chat-composer-message-details .chat-reply__username")+ expect(find(".chat-composer-input").value).to eq("")endendend