UX: Prevent category-drop topic count from wrapping to new line (#8943)
This commit is contained in:
parent
c36ae17260
commit
efa9ba4975
|
@ -151,6 +151,13 @@ function defaultCategoryLinkRenderer(category, opts) {
|
||||||
}
|
}
|
||||||
html += "</span>";
|
html += "</span>";
|
||||||
|
|
||||||
|
if (opts.topicCount) {
|
||||||
|
html += `<span class="topic-count" aria-label="${I18n.t(
|
||||||
|
"category_row.topic_count",
|
||||||
|
{ count: opts.topicCount }
|
||||||
|
)}">× ${opts.topicCount}</span>`;
|
||||||
|
}
|
||||||
|
|
||||||
if (href) {
|
if (href) {
|
||||||
href = ` href="${href}" `;
|
href = ` href="${href}" `;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,8 @@ export default SelectKitRowComponent.extend({
|
||||||
link: this.categoryLink,
|
link: this.categoryLink,
|
||||||
allowUncategorized:
|
allowUncategorized:
|
||||||
this.allowUncategorizedTopics || this.allowUncategorized,
|
this.allowUncategorizedTopics || this.allowUncategorized,
|
||||||
hideParent: !!this.parentCategory
|
hideParent: !!this.parentCategory,
|
||||||
|
topicCount: this.topicCount
|
||||||
}).htmlSafe();
|
}).htmlSafe();
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,6 @@
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{badgeForCategory}}
|
{{badgeForCategory}}
|
||||||
<span class="topic-count" aria-label={{i18n "category_row.topic_count" count=topicCount}}>
|
|
||||||
× {{topicCount}}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#if shouldDisplayDescription}}
|
{{#if shouldDisplayDescription}}
|
||||||
|
|
|
@ -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 => {
|
QUnit.test("allowUncategorized", assert => {
|
||||||
const store = createStore();
|
const store = createStore();
|
||||||
const uncategorized = store.createRecord("category", {
|
const uncategorized = store.createRecord("category", {
|
||||||
|
|
Loading…
Reference in New Issue