FIX: Use the category's text-only description in the category-chooser (#15735)

The category description is derived from a topic's cooked text and contains HTML elements. When we display it inside the category chooser in places like the composer, we don't want these elements to alter the component in any way.

Context: https://meta.discourse.org/t/some-html-tags-not-stripped-from-category-description/215017
This commit is contained in:
Roman Rizzi
2022-02-24 12:14:24 -03:00
committed by GitHub
parent e0b683f98e
commit 00bb5f3a9d
4 changed files with 48 additions and 13 deletions

View File

@@ -35,8 +35,6 @@ export default SelectKitRowComponent.extend({
}),
categoryName: reads("category.name"),
categoryDescription: reads("category.description"),
categoryDescriptionText: reads("category.description_text"),
category: computed("rowValue", "rowName", function () {
@@ -94,12 +92,12 @@ export default SelectKitRowComponent.extend({
shouldDisplayDescription: computed(
"displayCategoryDescription",
"categoryDescription",
"categoryDescriptionText",
function () {
return (
this.displayCategoryDescription &&
this.categoryDescription &&
this.categoryDescription !== "null"
this.categoryDescriptionText &&
this.categoryDescriptionText !== "null"
);
}
),
@@ -110,12 +108,6 @@ export default SelectKitRowComponent.extend({
}
}),
description: computed("categoryDescription", function () {
if (this.categoryDescription) {
return this._formatDescription(this.categoryDescription);
}
}),
_formatDescription(description) {
const limit = 200;
return `${description.substr(0, limit)}${

View File

@@ -9,7 +9,7 @@
</div>
{{#if shouldDisplayDescription}}
<div class="category-desc" aria-hidden="true">{{dir-span description htmlSafe="true"}}</div>
<div class="category-desc" aria-hidden="true">{{dir-span descriptionText htmlSafe="true"}}</div>
{{/if}}
{{else}}
{{html-safe label}}