mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: correctly highlights active channel (#18991)
Prior to this change, only hovering the row would highlight it.
This commit is contained in:
parent
dc8a7e74f4
commit
88ede43ec5
@ -253,6 +253,7 @@ export default Component.extend({
|
|||||||
close() {
|
close() {
|
||||||
this.set("hidden", true);
|
this.set("hidden", true);
|
||||||
this.set("expanded", false);
|
this.set("expanded", false);
|
||||||
|
this.chat.setActiveChannel(null);
|
||||||
this.appEvents.trigger("chat:float-toggled", this.hidden);
|
this.appEvents.trigger("chat:float-toggled", this.hidden);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import { emojiUnescape } from "discourse/lib/text";
|
|||||||
import { decorateUsername } from "discourse/helpers/decorate-username-selector";
|
import { decorateUsername } from "discourse/helpers/decorate-username-selector";
|
||||||
import { until } from "discourse/lib/formatter";
|
import { until } from "discourse/lib/formatter";
|
||||||
import { inject as service } from "@ember/service";
|
import { inject as service } from "@ember/service";
|
||||||
|
import { computed } from "@ember/object";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "chat-sidebar",
|
name: "chat-sidebar",
|
||||||
@ -60,10 +61,19 @@ export default {
|
|||||||
return dasherize(slugifyChannel(this.channel));
|
return dasherize(slugifyChannel(this.channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@computed("chatService.activeChannel")
|
||||||
get classNames() {
|
get classNames() {
|
||||||
return this.channel.current_user_membership.muted
|
const classes = [];
|
||||||
? "sidebar-section-link--muted"
|
|
||||||
: "";
|
if (this.channel.current_user_membership.muted) {
|
||||||
|
classes.push("sidebar-section-link--muted");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.channel.id === this.chatService.activeChannel?.id) {
|
||||||
|
classes.push("sidebar-section-link--active");
|
||||||
|
}
|
||||||
|
|
||||||
|
return classes.join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
get route() {
|
get route() {
|
||||||
@ -239,10 +249,19 @@ export default {
|
|||||||
return slugifyChannel(this.channel);
|
return slugifyChannel(this.channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@computed("chatService.activeChannel")
|
||||||
get classNames() {
|
get classNames() {
|
||||||
return this.channel.current_user_membership.muted
|
const classes = [];
|
||||||
? "sidebar-section-link--muted"
|
|
||||||
: "";
|
if (this.channel.current_user_membership.muted) {
|
||||||
|
classes.push("sidebar-section-link--muted");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.channel.id === this.chatService.activeChannel?.id) {
|
||||||
|
classes.push("sidebar-section-link--active");
|
||||||
|
}
|
||||||
|
|
||||||
|
return classes.join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
get route() {
|
get route() {
|
||||||
|
@ -162,6 +162,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebar-section-link--active {
|
||||||
|
background: var(--primary-low);
|
||||||
|
}
|
||||||
|
|
||||||
.sidebar-section-link--muted {
|
.sidebar-section-link--muted {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
|
|
||||||
|
@ -216,5 +216,50 @@ RSpec.describe "Navigation", type: :system, js: true do
|
|||||||
expect(page).to have_content(category_channel_2.title)
|
expect(page).to have_content(category_channel_2.title)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when opening a channel in full page" do
|
||||||
|
it "activates the channel in the sidebar" do
|
||||||
|
visit("/chat/channel/#{category_channel.id}/#{category_channel.slug}")
|
||||||
|
expect(page).to have_css(
|
||||||
|
".sidebar-section-link-#{category_channel.slug}.sidebar-section-link--active",
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when clicking logo from a channel in full page" do
|
||||||
|
it "deactivates the channel in the sidebar" do
|
||||||
|
visit("/chat/channel/#{category_channel.id}/#{category_channel.slug}")
|
||||||
|
find("#site-logo").click
|
||||||
|
|
||||||
|
expect(page).not_to have_css(
|
||||||
|
".sidebar-section-link-#{category_channel.slug}.sidebar-section-link--active",
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when opening a channel in drawer" do
|
||||||
|
it "activates the channel in the sidebar" do
|
||||||
|
visit("/")
|
||||||
|
chat_page.open_from_header
|
||||||
|
find("a[title='#{category_channel.title}']").click
|
||||||
|
|
||||||
|
expect(page).to have_css(
|
||||||
|
".sidebar-section-link-#{category_channel.slug}.sidebar-section-link--active",
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when closing drawer in a channel" do
|
||||||
|
it "deactivates the channel in the sidebar" do
|
||||||
|
visit("/")
|
||||||
|
chat_page.open_from_header
|
||||||
|
find("a[title='#{category_channel.title}']").click
|
||||||
|
chat_drawer_page.close
|
||||||
|
|
||||||
|
expect(page).not_to have_css(
|
||||||
|
".sidebar-section-link-#{category_channel.slug}.sidebar-section-link--active",
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user