Skip to content

A platform for community discussion. Free, open, simple.

UX: orders public channels by slug instead of title (#20188)

Joffrey JAFFEUXf4b56ea4552b
diff --git a/plugins/chat/assets/javascripts/discourse/services/chat-channels-manager.js b/plugins/chat/assets/javascripts/discourse/services/chat-channels-manager.js
index 9d2cae55392..e70655e3585 100644
--- a/plugins/chat/assets/javascripts/discourse/services/chat-channels-manager.js
+++ b/plugins/chat/assets/javascripts/discourse/services/chat-channels-manager.js
@@ -99,7 +99,7 @@ export default class ChatChannelsManager extends Service {
(channel) =>
channel.isCategoryChannel && channel.currentUserMembership.following
)
- .sort((a, b) => a.title.localeCompare(b.title));
+ .sort((a, b) => a?.slug?.localeCompare?.(b?.slug));
}
get directMessageChannels() {
diff --git a/plugins/chat/spec/system/list_channels/sidebar_spec.rb b/plugins/chat/spec/system/list_channels/sidebar_spec.rb
index f7c4889c569..527930d8e3a 100644
--- a/plugins/chat/spec/system/list_channels/sidebar_spec.rb
+++ b/plugins/chat/spec/system/list_channels/sidebar_spec.rb
@@ -42,15 +42,15 @@ RSpec.describe "List channels | sidebar", type: :system, js: true do
end
context "when multiple category channels are present" do
- fab!(:channel_1) { Fabricate(:category_channel, name: "b channel") }
- fab!(:channel_2) { Fabricate(:category_channel, name: "a channel") }
+ fab!(:channel_1) { Fabricate(:category_channel, name: ":art: b channel") }
+ fab!(:channel_2) { Fabricate(:category_channel, name: ":art: a channel") }
before do
channel_1.add(current_user)
channel_2.add(current_user)
end
- it "sorts them alphabetically" do
+ it "sorts them by slug" do
visit("/")
expect(page.find("#sidebar-section-content-chat-channels li:nth-child(1)")).to have_css(