Skip to content

A platform for community discussion. Free, open, simple.

FIX: missing category on composer when lazy_load_categories (#37484)

Renato Atilio6372ac40fc81
diff --git a/frontend/discourse/app/models/composer.js b/frontend/discourse/app/models/composer.js
index 39e77eb9969..54799a5f658 100644
--- a/frontend/discourse/app/models/composer.js
+++ b/frontend/discourse/app/models/composer.js
@@ -326,7 +326,8 @@ export default class Composer extends RestModel {
@discourseComputed("privateMessage", "archetype.hasOptions")
showCategoryChooser(isPrivateMessage, hasOptions) {
- const manyCategories = this.site.categories.length > 1;
+ const manyCategories =
+ this.site.lazy_load_categories || this.site.categories.length > 1;
return !isPrivateMessage && (hasOptions || manyCategories);
}
diff --git a/frontend/discourse/tests/unit/models/composer-test.js b/frontend/discourse/tests/unit/models/composer-test.js
index f7f87ea2926..da6634c442f 100644
--- a/frontend/discourse/tests/unit/models/composer-test.js
+++ b/frontend/discourse/tests/unit/models/composer-test.js
@@ -543,4 +543,17 @@ module("Unit | Model | composer", function (hooks) {
"original_tags are kept as objects for backend to extract IDs"
);
});
+
+ test("showCategoryChooser with lazy loaded categories", function (assert) {
+ const site = getOwner(this).lookup("service:site");
+ site.set("lazy_load_categories", true);
+ site.set("categories", []);
+
+ const composer = createComposer.call(this, { action: CREATE_TOPIC });
+
+ assert.true(
+ composer.showCategoryChooser,
+ "shows category chooser when lazy_load_categories is enabled even with no categories loaded"
+ );
+ });
});