FIX: update minimum required tag when switching categories in composer

FIX: update minimum required tag when switching categories in composer

diff --git a/app/assets/javascripts/select-kit/addon/components/mini-tag-chooser.js b/app/assets/javascripts/select-kit/addon/components/mini-tag-chooser.js
index 94b9fa0..5c7035a 100644
--- a/app/assets/javascripts/select-kit/addon/components/mini-tag-chooser.js
+++ b/app/assets/javascripts/select-kit/addon/components/mini-tag-chooser.js
@@ -10,7 +10,6 @@ const SELECTED_TAGS_COLLECTION = "MINI_TAG_CHOOSER_SELECTED_TAGS";
 import { ERRORS_COLLECTION } from "select-kit/components/select-kit";
 
 export default ComboBox.extend(TagsMixin, {
-  headerComponent: "mini-tag-chooser/mini-tag-chooser-header",
   pluginApiIdentifiers: ["mini-tag-chooser"],
   attributeBindings: ["selectKit.options.categoryId:category-id"],
   classNames: ["mini-tag-chooser"],
@@ -31,6 +30,7 @@ export default ComboBox.extend(TagsMixin, {
   ),
 
   selectKitOptions: {
+    headerComponent: "mini-tag-chooser/mini-tag-chooser-header",
     fullWidthOnMobile: true,
     filterable: true,
     caretDownIcon: "caretIcon",
diff --git a/app/assets/javascripts/select-kit/addon/components/single-select.js b/app/assets/javascripts/select-kit/addon/components/single-select.js
index 7338d80..12ed3fe 100644
--- a/app/assets/javascripts/select-kit/addon/components/single-select.js
+++ b/app/assets/javascripts/select-kit/addon/components/single-select.js
@@ -12,31 +12,36 @@ export default SelectKitComponent.extend({
     headerComponent: "select-kit/single-select-header"
   },
 
-  selectedContent: computed("value", "content.[]", function() {
-    if (!isEmpty(this.value)) {
-      let content;
+  selectedContent: computed(
+    "value",
+    "content.[]",
+    "selectKit.noneItem",
+    function() {
+      if (!isEmpty(this.value)) {
+        let content;
 
-      const value =
-        this.selectKit.options.castInteger && this._isNumeric(this.value)
-          ? Number(this.value)
-          : this.value;
+        const value =
+          this.selectKit.options.castInteger && this._isNumeric(this.value)
+            ? Number(this.value)
+            : this.value;
 
-      if (this.selectKit.valueProperty) {
-        content = (this.content || []).findBy(
-          this.selectKit.valueProperty,
-          value
-        );
+        if (this.selectKit.valueProperty) {
+          content = (this.content || []).findBy(
+            this.selectKit.valueProperty,
+            value
+          );
 
-        return this.selectKit.modifySelection(
-          content || this.defaultItem(value, value)
-        );
+          return this.selectKit.modifySelection(
+            content || this.defaultItem(value, value)
+          );
+        } else {
+          return this.selectKit.modifySelection(
+            (this.content || []).filter(c => c === value)
+          );
+        }
       } else {
-        return this.selectKit.modifySelection(
-          (this.content || []).filter(c => c === value)
-        );
+        return this.selectKit.noneItem;
       }
-    } else {
-      return this.selectKit.noneItem;
     }
-  })
+  )
 });

GitHub sha: c5b1f028

1 Like