From 79cacba9487be9bf2b5fefdcf8805abb92ef740f Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Fri, 7 Apr 2023 09:55:55 +0200 Subject: [PATCH] FIX: cancel editing should clear the composer (#21011) --- .../discourse/components/chat-composer.hbs | 2 +- .../discourse/components/chat-composer.js | 5 ++--- .../discourse/components/chat-live-pane.hbs | 1 - .../javascripts/discourse/components/chat-thread.hbs | 1 - plugins/chat/spec/system/chat_composer_spec.rb | 12 ++++++++++++ 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-composer.hbs index 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 @@ {{/if}} diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-composer.js b/plugins/chat/assets/javascripts/discourse/components/chat-composer.js index 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, { @action cancelEditing() { 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.hbs index 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)}}