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

This commit is contained in:
Penar Musaraj 2022-03-30 21:57:27 -04:00 committed by GitHub
parent 943083f4df
commit e431000b23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 6 deletions

View File

@ -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"
);
},
});
}

View File

@ -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;
});