FIX: error with tags enabled and no tags created (#6701)

FIX: error with tags enabled and no tags created (#6701)

From 4c7dfed32ea39cde85d575ae4b60fe2a70899c76 Mon Sep 17 00:00:00 2001
From: Joffrey JAFFEUX <j.jaffeux@gmail.com>
Date: Thu, 29 Nov 2018 10:39:09 +0100
Subject: [PATCH] FIX: error with tags enabled and no tags created (#6701)


diff --git a/app/assets/javascripts/select-kit/components/tag-drop.js.es6 b/app/assets/javascripts/select-kit/components/tag-drop.js.es6
index 25f20d6..d5262fe 100644
--- a/app/assets/javascripts/select-kit/components/tag-drop.js.es6
+++ b/app/assets/javascripts/select-kit/components/tag-drop.js.es6
@@ -120,7 +120,7 @@ export default ComboBoxComponent.extend(TagsMixin, {
     if (this.siteSettings.tags_sort_alphabetically && topTags) {
       return shortcuts.concat(topTags.sort());
     } else {
-      return shortcuts.concat(topTags);
+      return shortcuts.concat(Ember.makeArray(topTags));
     }
   },
 
diff --git a/test/javascripts/components/tag-drop-test.js.es6 b/test/javascripts/components/tag-drop-test.js.es6
index c815abf..ae1003a 100644
--- a/test/javascripts/components/tag-drop-test.js.es6
+++ b/test/javascripts/components/tag-drop-test.js.es6
@@ -83,3 +83,24 @@ componentTest("default", {
     );
   }
 });
+
+componentTest("no tags", {
+  template: "{{tag-drop}}",
+
+  beforeEach() {
+    this.site.set("can_create_tag", true);
+    this.set("site.top_tags", undefined);
+  },
+
+  async test(assert) {
+    await this.get("subject").expand();
+
+    assert.equal(
+      this.get("subject")
+        .rowByIndex(1)
+        .name(),
+      undefined,
+      "it has no tags and doesn’t crash"
+    );
+  }
+});

GitHub

1 Like

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