FIX: category-selector for top level categories (#24627)

The filter for top-level categories by using parent_category_id = -1 is
only implemented by the new search API.

Follow up to commit dbb8b66a37.
This commit is contained in:
Bianca Nenciu 2023-11-29 13:29:18 +02:00 committed by GitHub
parent d38360b23f
commit 1881ae50be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -134,14 +134,10 @@ export default ComboBoxComponent.extend({
),
async search(filter) {
const opts = {
parentCategoryId: this.options.parentCategory?.id || -1,
includeUncategorized: this.siteSettings.allow_uncategorized_topics,
};
if (this.siteSettings.lazy_load_categories) {
const results = await Category.asyncSearch(filter, {
...opts,
parentCategoryId: this.options.parentCategory?.id || -1,
includeUncategorized: this.siteSettings.allow_uncategorized_topics,
limit: 15,
});
return this.shortcuts.concat(
@ -157,6 +153,10 @@ export default ComboBoxComponent.extend({
);
}
const opts = {
parentCategoryId: this.options.parentCategory?.id,
};
if (filter) {
let results = Category.search(filter, opts);
return this._filterUncategorized(results).sort((a, b) => {