mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 13:28:13 +08:00
FIX: correctly closes panels in threads (#31013)
The following case was bugged:
- visit a thread in full page chat
- click channel title
- click back button in channel navbar
- 💥 you would have a channel with limited width as if there was
still the thread showing next to it, but it was empty
This commit is contained in:
@ -6,7 +6,6 @@ export default class ChatChannelThread extends DiscourseRoute {
|
|||||||
@service router;
|
@service router;
|
||||||
@service chatStateManager;
|
@service chatStateManager;
|
||||||
@service chat;
|
@service chat;
|
||||||
@service chatThreadPane;
|
|
||||||
|
|
||||||
redirectToChannel(channel, transition) {
|
redirectToChannel(channel, transition) {
|
||||||
transition.abort();
|
transition.abort();
|
||||||
@ -36,15 +35,14 @@ export default class ChatChannelThread extends DiscourseRoute {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
willTransition(transition) {
|
activate() {
|
||||||
if (
|
this.chat.activeMessage = null;
|
||||||
transition.targetName === "chat.channel.index" ||
|
this.chatStateManager.openSidePanel();
|
||||||
transition.targetName === "chat.channel.near-message" ||
|
|
||||||
transition.targetName === "chat.index" ||
|
|
||||||
!transition.targetName.startsWith("chat")
|
|
||||||
) {
|
|
||||||
this.chatStateManager.closeSidePanel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
deactivate() {
|
||||||
|
this.chatStateManager.closeSidePanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeModel() {
|
beforeModel() {
|
||||||
@ -55,7 +53,5 @@ export default class ChatChannelThread extends DiscourseRoute {
|
|||||||
) {
|
) {
|
||||||
this.controllerFor("chat-channel-thread").set("targetMessageId", null);
|
this.controllerFor("chat-channel-thread").set("targetMessageId", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.chatStateManager.openSidePanel();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,24 +16,16 @@ export default class ChatChannelThreads extends DiscourseRoute {
|
|||||||
this.router.transitionTo("chat.channel", ...channel.routeModels);
|
this.router.transitionTo("chat.channel", ...channel.routeModels);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.chatStateManager.openSidePanel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
activate() {
|
activate() {
|
||||||
this.chat.activeMessage = null;
|
this.chat.activeMessage = null;
|
||||||
|
this.chatStateManager.openSidePanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
willTransition(transition) {
|
deactivate() {
|
||||||
if (
|
|
||||||
transition.targetName === "chat.channel.index" ||
|
|
||||||
transition.targetName === "chat.channel.near-message" ||
|
|
||||||
transition.targetName === "chat.index" ||
|
|
||||||
!transition.targetName.startsWith("chat")
|
|
||||||
) {
|
|
||||||
this.chatStateManager.closeSidePanel();
|
this.chatStateManager.closeSidePanel();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -139,6 +139,24 @@ RSpec.describe "Navigation", type: :system do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when opening channel settings from thread" do
|
||||||
|
fab!(:thread) { Fabricate(:chat_thread, channel: category_channel, use_service: true) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
category_channel.update!(threading_enabled: true)
|
||||||
|
Fabricate(:chat_message, thread: thread, use_service: true)
|
||||||
|
thread.add(current_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "correctly closes the side panel" do
|
||||||
|
chat_page.visit_thread(thread)
|
||||||
|
|
||||||
|
find(".c-navbar__channel-title").click
|
||||||
|
|
||||||
|
expect(page).to have_no_selector(".main-chat-outlet.has-side-panel-expanded")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "when collapsing full page with no previous state" do
|
context "when collapsing full page with no previous state" do
|
||||||
it "redirects to home page" do
|
it "redirects to home page" do
|
||||||
chat_page.open
|
chat_page.open
|
||||||
|
Reference in New Issue
Block a user