A platform for community discussion. Free, open, simple.
FIX: ensures topic count is correctly showing in box category badges (#9034)
Joffrey JAFFEUXbd49368942fc
diff --git a/app/assets/javascripts/discourse/helpers/category-link.js.es6 b/app/assets/javascripts/discourse/helpers/category-link.js.es6index f2ec739038d..5199eda96ae 100644--- a/app/assets/javascripts/discourse/helpers/category-link.js.es6+++ b/app/assets/javascripts/discourse/helpers/category-link.js.es6@@ -86,6 +86,13 @@ export function categoryLinkHTML(category, options) {registerUnbound("category-link", categoryLinkHTML);+function buildTopicCount(count) {+ return `<span class="topic-count" aria-label="${I18n.t(+ "category_row.topic_count",+ { count }+ )}">× ${count}</span>`;+}+function defaultCategoryLinkRenderer(category, opts) {let descriptionText = get(category, "description_text");let restricted = get(category, "read_restricted");@@ -151,11 +158,8 @@ function defaultCategoryLinkRenderer(category, opts) {}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 (opts.topicCount && categoryStyle !== "box") {+ html += buildTopicCount(opts.topicCount);}if (href) {@@ -163,5 +167,10 @@ function defaultCategoryLinkRenderer(category, opts) {}extraClasses = categoryStyle ? categoryStyle + extraClasses : extraClasses;- return `<${tagName} class="badge-wrapper ${extraClasses}" ${href}>${html}</${tagName}>`;++ let afterBadgeWrapper = "";+ if (opts.topicCount && categoryStyle === "box") {+ afterBadgeWrapper += buildTopicCount(opts.topicCount);+ }+ return `<${tagName} class="badge-wrapper ${extraClasses}" ${href}>${html}</${tagName}>${afterBadgeWrapper}`;}diff --git a/app/assets/stylesheets/common/select-kit/category-chooser.scss b/app/assets/stylesheets/common/select-kit/category-chooser.scssindex 4b5e7b2461b..695e5390530 100644--- a/app/assets/stylesheets/common/select-kit/category-chooser.scss+++ b/app/assets/stylesheets/common/select-kit/category-chooser.scss@@ -25,7 +25,7 @@font-size: $font-down-1;color: $primary;white-space: nowrap;- margin-left: 1em;+ margin-left: 0.5em;font-weight: normal;}