FIX: Make edit categories sidebar modal work more intuitively (#27111)

* Load search results in displayed order so that when more categories are loaded on scroll, they appear at the end,
 * Limit the number of subcategories that are shown per category and display 'show more' links,
This commit is contained in:
Daniel Waterworth
2024-06-14 11:37:32 -05:00
committed by GitHub
parent 831b1fee36
commit 63e8c79e2f
10 changed files with 586 additions and 217 deletions

View File

@ -1550,4 +1550,19 @@ RSpec.describe Category do
)
end
end
describe ".limited_categories_matching" do
before_all { SiteSetting.max_category_nesting = 3 }
fab!(:foo) { Fabricate(:category, name: "foo") }
fab!(:bar) { Fabricate(:category, name: "bar", parent_category: foo) }
fab!(:baz) { Fabricate(:category, name: "baz", parent_category: bar) }
it "produces results in depth-first pre-order" do
SiteSetting.max_category_nesting = 3
expect(Category.limited_categories_matching(nil, nil, nil, "baz").pluck(:name)).to eq(
%w[foo bar baz],
)
end
end
end