DEV: Close the pinned messages list on Esc (#38267)

This commit is contained in:
Jarek Radosz
2026-03-05 10:26:19 +01:00
committed by GitHub
parent ad438f4000
commit 4fc6fc975c
3 changed files with 33 additions and 0 deletions
@@ -131,6 +131,16 @@ export default {
chatThreadListPane.close();
return;
}
if (chatStateManager.isPinnedMessagesPaneOpen) {
event.preventDefault();
event.stopPropagation();
router.transitionTo(
"chat.channel",
...chatService.activeChannel.routeModels
);
return;
}
};
const markAllChannelsRead = (event) => {
@@ -165,6 +165,10 @@ export default class ChatStateManager extends Service {
return this.isFullPageActive || this.isDrawerActive;
}
get isPinnedMessagesPaneOpen() {
return this.router.currentRouteName === "chat.channel.pins";
}
storeAppURL(url = null) {
if (url) {
this._appURL = url;
@@ -24,6 +24,25 @@ RSpec.describe "Shortcuts | full page", type: :system do
end
end
context "when pressing Esc" do
fab!(:message) { Fabricate(:chat_message, chat_channel: channel_1, use_service: true) }
fab!(:pin) { Fabricate(:chat_pinned_message, chat_message: message, user: current_user) }
before { SiteSetting.chat_pinned_messages = true }
it "closes the pinned messages list" do
chat.visit_channel(channel_1)
find(".c-navbar__pinned-messages-btn").click
expect(page).to have_css(".c-routes.--channel-pins")
page.send_keys(:escape)
expect(page).to have_no_css(".c-routes.--channel-pins")
expect(page).to have_current_path(channel_1.url)
end
end
context "with chat search" do
context "when disabled" do
before { SiteSetting.chat_search_enabled = false }