From a77d469eeb28941b8ea81babdb36d639400e8a58 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Fri, 21 Feb 2025 00:10:02 +0100 Subject: [PATCH] UX: close thread panel with a single escape (#31426) Before this commit we were requiring two escapes: - one to un-focus composer - one to close panel --- .../discourse/components/chat/composer/thread.js | 11 +++-------- .../system/chat/composer/shortcuts/thread_spec.rb | 12 +----------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/composer/thread.js b/plugins/chat/assets/javascripts/discourse/components/chat/composer/thread.js index ce346fb16ac..6928783794d 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat/composer/thread.js +++ b/plugins/chat/assets/javascripts/discourse/components/chat/composer/thread.js @@ -73,13 +73,8 @@ export default class ChatComposerThread extends ChatComposer { return; } - if (this.isFocused) { - event.stopPropagation(); - this.composer.blur(); - } else { - this.pane.close().then(() => { - this.channelComposer.focus(); - }); - } + this.pane.close().then(() => { + this.channelComposer.focus(); + }); } } diff --git a/plugins/chat/spec/system/chat/composer/shortcuts/thread_spec.rb b/plugins/chat/spec/system/chat/composer/shortcuts/thread_spec.rb index 3b5b1a1dc9b..7ce496831be 100644 --- a/plugins/chat/spec/system/chat/composer/shortcuts/thread_spec.rb +++ b/plugins/chat/spec/system/chat/composer/shortcuts/thread_spec.rb @@ -19,19 +19,9 @@ RSpec.describe "Chat | composer | shortcuts | thread", type: :system do end describe "Escape" do - context "when composer is focused" do - it "blurs the composer" do - chat_page.visit_thread(thread_1) - thread_page.composer.focus - thread_page.composer.cancel_shortcut - - expect(side_panel_page).to have_open_thread - end - end - it "closes the thread panel" do chat_page.visit_thread(thread_1) - thread_page.composer.cancel_shortcut # ensures we are not focused in the composer + page.send_keys(:escape) expect(side_panel_page).to have_no_open_thread