FIX: Category drop shows undefined (#11090)

FIX: Category drop shows undefined (#11090)

After 5fc239b535ece3e4b0c70298b2bc6c62f160d373, the category dropdown was showing “undefined” for the “all-categories” and “no-categories” messages. This commit introduces a check to run the HTML parser only if we’re dealing with a real category, which fixes the above issue.

diff --git a/app/assets/javascripts/select-kit/addon/components/category-row.js b/app/assets/javascripts/select-kit/addon/components/category-row.js
index 6026f45..cbcb6df 100644
--- a/app/assets/javascripts/select-kit/addon/components/category-row.js
+++ b/app/assets/javascripts/select-kit/addon/components/category-row.js
@@ -39,9 +39,11 @@ export default SelectKitRowComponent.extend({
     "description",
     "categoryName",
     function () {
-      return htmlToText(
-        this.descriptionText || this.description || this.categoryName
-      );
+      if (this.category) {
+        return htmlToText(
+          this.descriptionText || this.description || this.categoryName
+        );
+      }
     }
   ),
 

GitHub sha: 7b312b7b

This commit appears in #11090 which was approved by eviltrout. It was merged by justindirose.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/categories-show-as-undefined/168766/7