Skip to content

Commit

Permalink
DEV: Reorder categories in sidebar edit modal (discourse#25792)
Browse files Browse the repository at this point in the history
Sort categories by relevance instead of alphabetically.
  • Loading branch information
danielwaterworth authored Feb 21, 2024
1 parent 087712c commit 9db009b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ export default class extends Component {

if (this.siteSettings.fixed_category_positions) {
allCategories.sort((a, b) => a.position - b.position);
} else {
allCategories.sort((a, b) => a.name.localeCompare(b.name));
}

this.filteredCategoriesGroupings = splitWhere(
Expand Down
18 changes: 9 additions & 9 deletions spec/system/editing_sidebar_categories_navigation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
expect(modal).to have_no_reset_to_defaults_button

expect(modal).to have_categories(
[category, category_subcategory, category_subcategory2, category2, category2_subcategory],
[category2, category2_subcategory, category, category_subcategory2, category_subcategory],
)

modal
Expand Down Expand Up @@ -165,13 +165,13 @@
modal.filter("subcategory")

expect(modal).to have_categories(
[category, category_subcategory, category_subcategory2, category2, category2_subcategory],
[category2, category2_subcategory, category, category_subcategory2, category_subcategory],
)

modal.filter("2")

expect(modal).to have_categories(
[category, category_subcategory2, category2, category2_subcategory],
[category2, category2_subcategory, category, category_subcategory2],
)

modal.filter("someinvalidterm")
Expand All @@ -190,7 +190,7 @@
modal = sidebar.click_edit_categories_button
modal.filter_by_selected

expect(modal).to have_categories([category, category_subcategory, category2])
expect(modal).to have_categories([category2, category, category_subcategory])
expect(modal).to have_checkbox(category, disabled: true)
expect(modal).to have_checkbox(category_subcategory)
expect(modal).to have_checkbox(category2)
Expand All @@ -215,7 +215,7 @@
modal.filter_by_all

expect(modal).to have_categories(
[category, category_subcategory, category_subcategory2, category2, category2_subcategory],
[category, category_subcategory2, category_subcategory, category2, category2_subcategory],
)

expect(modal).to have_checkbox(category)
Expand Down Expand Up @@ -294,13 +294,13 @@

expect(modal).to have_categories(
[
category,
category_subcategory,
category_subcategory_subcategory2,
category_subcategory2,
category2,
category2_subcategory,
category2_subcategory_subcategory,
category,
category_subcategory2,
category_subcategory,
category_subcategory_subcategory2,
],
)
end
Expand Down

0 comments on commit 9db009b

Please sign in to comment.