Skip to content

Commit 4ecdbaf

Browse files
author
Yuriy Kurant
authored
FIX: show categories dropdown filter for user groups in lazy_load_categories_groups (#36218)
Categories filter now appears in the dropdown for lazy loaded categories. <img width="293" height="404" alt="Screenshot 2025-11-26 at 10 39 22" src="https://github.com/user-attachments/assets/055b414d-e867-4d32-a8d2-ff762eb0c752" /> ### Context For users in `lazy_load_categories_groups`, the filter was not rendered, because the initial category list was below the threshold. The logic controlling filter's visibility ignored the async scenario. ### Changes For users in `lazy_load_categories_groups`, `autoFilterable` setting is set to `true` regardless of a number of categories.
1 parent 1f7ac1b commit 4ecdbaf

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

frontend/discourse/select-kit/components/category-drop.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const MORE_COLLECTION = "MORE_COLLECTION";
4242
headerComponent: CategoryDropHeader,
4343
parentCategory: false,
4444
allowUncategorized: "allowUncategorized",
45+
autoFilterable: "autoFilterable",
4546
})
4647
@pluginApiIdentifiers(["category-drop"])
4748
export default class CategoryDrop extends ComboBoxComponent {
@@ -87,6 +88,11 @@ export default class CategoryDrop extends ComboBoxComponent {
8788
return this.options.subCategory || false;
8889
}
8990

91+
@computed("content.length", "site.lazy_load_categories")
92+
get autoFilterable() {
93+
return this.site.lazy_load_categories || this.content.length >= 10;
94+
}
95+
9096
@computed("value", "selectKit.options.{subCategory,noSubcategories}")
9197
get shortcuts() {
9298
const shortcuts = [];

spec/system/categories_page_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,38 @@
3838
expect(subcategory_selector).to have_selected_name(subcategory.name)
3939
end
4040
end
41+
42+
describe "dropdown filter" do
43+
it "is shown for users in lazy_load_categories_groups" do
44+
SiteSetting.lazy_load_categories_groups = "admins"
45+
sign_in(admin)
46+
category_page.visit_general(category)
47+
category_selector =
48+
PageObjects::Components::SelectKit.new(".category-breadcrumb__category-selector")
49+
50+
expect(category_selector).to have_filter
51+
end
52+
53+
it "is not shown if categories are up to 10" do
54+
sign_in(admin)
55+
category_page.visit_general(category)
56+
category_selector =
57+
PageObjects::Components::SelectKit.new(".category-breadcrumb__category-selector")
58+
59+
expect(category_selector).to have_no_filter
60+
end
61+
62+
context "when categories are 10 or more" do
63+
fab!(:categories) { Fabricate.times(8, :category) }
64+
65+
it "is shown" do
66+
sign_in(admin)
67+
category_page.visit_general(category)
68+
category_selector =
69+
PageObjects::Components::SelectKit.new(".category-breadcrumb__category-selector")
70+
71+
expect(category_selector).to have_filter
72+
end
73+
end
74+
end
4175
end

spec/system/page_objects/components/select_kit.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ def collapse
9292
collapsed_component
9393
end
9494

95+
def has_filter?
96+
expanded_component.has_css?(".select-kit-filter .filter-input", visible: true)
97+
end
98+
99+
def has_no_filter?
100+
expanded_component.has_no_css?(".select-kit-filter .filter-input")
101+
end
102+
95103
def search(value = nil)
96104
expanded_component.find(".select-kit-filter .filter-input").fill_in(with: value)
97105
end

0 commit comments

Comments
 (0)