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

Public channels were previously sorted by name, however, channels with a leading emoji in the name would always appear first in the list. By using slug we avoid this issue.
This commit is contained in:
Joffrey JAFFEUX 2023-02-07 10:36:28 +01:00 committed by GitHub
parent 19ff8210bc
commit f4b56ea455
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -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() {

View File

@ -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(