Skip to content

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

FIX: Hide tag count in tag filter when in a category context (#16327)

Penar Musaraje431000b23bf
diff --git a/app/assets/javascripts/discourse/tests/integration/components/select-kit/tag-drop-test.js b/app/assets/javascripts/discourse/tests/integration/components/select-kit/tag-drop-test.js
index 1735d87166a..d745244802c 100644
--- a/app/assets/javascripts/discourse/tests/integration/components/select-kit/tag-drop-test.js
+++ b/app/assets/javascripts/discourse/tests/integration/components/select-kit/tag-drop-test.js
@@ -36,11 +36,7 @@ discourseModule(
};
pretender.get("/tags/filter/search", (params) => {
- if (params.queryParams.q === "rég") {
- return response({
- results: [{ id: "régis", name: "régis", count: 2, pm_count: 0 }],
- });
- } else if (params.queryParams.q === "dav") {
+ if (params.queryParams.q === "dav") {
return response({
results: [{ id: "David", name: "David", count: 2, pm_count: 0 }],
});
@@ -85,6 +81,32 @@ discourseModule(
I18n.t("tagging.selector_all_tags"),
"it has the correct label for all-tags"
);
+
+ await this.subject.fillInFilter("dav");
+
+ assert.strictEqual(
+ this.subject.rows()[0].textContent.trim(),
+ "David",
+ "it has no tag count when filtering in a category context"
+ );
+ },
+ });
+
+ componentTest("default global (no category)", {
+ template: hbs`{{tag-drop}}`,
+
+ async test(assert) {
+ await this.subject.expand();
+
+ assert.ok(true);
+
+ await this.subject.fillInFilter("dav");
+
+ assert.strictEqual(
+ this.subject.rows()[0].textContent.trim(),
+ "David x2",
+ "it has the tag count"
+ );
},
});
}
diff --git a/app/assets/javascripts/select-kit/addon/components/tag-drop.js b/app/assets/javascripts/select-kit/addon/components/tag-drop.js
index 9bd4bc5a019..971af05cf13 100644
--- a/app/assets/javascripts/select-kit/addon/components/tag-drop.js
+++ b/app/assets/javascripts/select-kit/addon/components/tag-drop.js
@@ -157,7 +157,9 @@ export default ComboBoxComponent.extend(TagsMixin, {
.map((r) => {
const content = context.defaultItem(r.id, r.text);
content.targetTagId = r.target_tag || r.id;
- content.count = r.count;
+ if (!context.currentCategory) {
+ content.count = r.count;
+ }
content.pmCount = r.pm_count;
return content;
});