Users are not able to edit category navigation since introduction of partial loaded categories

We have a lot of categories and only a small subset of them is visible for normal users.

Except for admins, subcategories are not shown to most users in the “Edit category navigation”-modal.

If I increase the number of included subcategories in Category scope :limited_categories_matching (source) from 5 to some number, which effectively disables partial loading, the missing categories are shown.

My conjecture is that unless coincidentally the subcategories visible to the user are among the first five subcategories, they will be removed from the result set by the permission check, resulting in the absence of a “load more” element in the editor.

I would be happy if the number of search results could be made configurable as a quick fix.

Side note: categories-modal.gjs assumes that there are more categories to load if the number of shown categories is 5, which also happens if there are exactly 5 categories to show, even if all subcategories are loaded using the patch above.

In the meantime, I use this template to fix this issue:

run:
  - replace:
      filename: "/var/www/discourse/app/models/category.rb"
      from: "select_descendants(Category.from(\"matches\").select(:matches, :id), 5"
      to: "select_descendants(Category.from(\"matches\").select(:matches, :id), 500"

Thank you for the bug report, Thomas. We have implemented a fix in this PR:

2 Likes