diff --git a/app/assets/javascripts/discourse/helpers/category-link.js.es6 b/app/assets/javascripts/discourse/helpers/category-link.js.es6
index a9867dac2a..f2ec739038 100644
--- a/app/assets/javascripts/discourse/helpers/category-link.js.es6
+++ b/app/assets/javascripts/discourse/helpers/category-link.js.es6
@@ -151,6 +151,13 @@ function defaultCategoryLinkRenderer(category, opts) {
}
html += "";
+ if (opts.topicCount) {
+ html += `× ${opts.topicCount}`;
+ }
+
if (href) {
href = ` href="${href}" `;
}
diff --git a/app/assets/javascripts/select-kit/components/category-row.js.es6 b/app/assets/javascripts/select-kit/components/category-row.js.es6
index fe3639e20e..e861debd27 100644
--- a/app/assets/javascripts/select-kit/components/category-row.js.es6
+++ b/app/assets/javascripts/select-kit/components/category-row.js.es6
@@ -53,7 +53,8 @@ export default SelectKitRowComponent.extend({
link: this.categoryLink,
allowUncategorized:
this.allowUncategorizedTopics || this.allowUncategorized,
- hideParent: !!this.parentCategory
+ hideParent: !!this.parentCategory,
+ topicCount: this.topicCount
}).htmlSafe();
}),
diff --git a/app/assets/javascripts/select-kit/templates/components/category-row.hbs b/app/assets/javascripts/select-kit/templates/components/category-row.hbs
index e9356359dc..db51a397f8 100644
--- a/app/assets/javascripts/select-kit/templates/components/category-row.hbs
+++ b/app/assets/javascripts/select-kit/templates/components/category-row.hbs
@@ -6,9 +6,6 @@
{{/unless}}
{{/if}}
{{badgeForCategory}}
-
- × {{topicCount}}
-
{{#if shouldDisplayDescription}}
diff --git a/test/javascripts/lib/category-badge-test.js.es6 b/test/javascripts/lib/category-badge-test.js.es6
index 965899eb11..2feb0a2f5a 100644
--- a/test/javascripts/lib/category-badge-test.js.es6
+++ b/test/javascripts/lib/category-badge-test.js.es6
@@ -46,6 +46,21 @@ QUnit.test("undefined color", assert => {
);
});
+QUnit.test("topic count", assert => {
+ const store = createStore();
+ const category = store.createRecord("category", { name: "hello", id: 123 });
+
+ assert.equal(
+ categoryBadgeHTML(category).indexOf("topic-count"),
+ -1,
+ "it does not include topic count by default"
+ );
+ assert.ok(
+ categoryBadgeHTML(category, { topicCount: 20 }).indexOf("topic-count") > 20,
+ "is included when specified"
+ );
+});
+
QUnit.test("allowUncategorized", assert => {
const store = createStore();
const uncategorized = store.createRecord("category", {