From fc5c0270f79b42675bf617e24036b8f65b108093 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Fri, 8 Nov 2024 09:19:24 +0900 Subject: [PATCH] FIX: ensures thread panel closes on escape (#29651) `chatThreadPane.isOpened` was returning `false` when it should return `true` due to an incorrect matching on the route. Note that visiting a thread will focus the composer and the first escape will blur the input, only the second will close the panel. --- .../javascripts/discourse/services/chat-thread-pane.js | 5 ++++- .../spec/system/chat/composer/shortcuts/thread_spec.rb | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/chat/assets/javascripts/discourse/services/chat-thread-pane.js b/plugins/chat/assets/javascripts/discourse/services/chat-thread-pane.js index 6372b9ad363..e3445361868 100644 --- a/plugins/chat/assets/javascripts/discourse/services/chat-thread-pane.js +++ b/plugins/chat/assets/javascripts/discourse/services/chat-thread-pane.js @@ -10,7 +10,10 @@ export default class ChatThreadPane extends ChatChannelPane { } get isOpened() { - return this.router.currentRoute.name === "chat.channel.thread"; + return ( + this.router.currentRoute.name === "chat.channel.thread" || + this.router.currentRoute.name === "chat.channel.thread.index" + ); } get selectedMessageIds() { 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 7ba0dc37041..3b5b1a1dc9b 100644 --- a/plugins/chat/spec/system/chat/composer/shortcuts/thread_spec.rb +++ b/plugins/chat/spec/system/chat/composer/shortcuts/thread_spec.rb @@ -28,6 +28,14 @@ RSpec.describe "Chat | composer | shortcuts | thread", type: :system do 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 + end end describe "ArrowUp" do