From 43920827ed29bc2dfbceeec85958287206235e21 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 30 Oct 2017 01:28:11 -0700 Subject: [PATCH] FIX: makes sure the combo-box selects the first value --- .../discourse/components/edit-category-security.js.es6 | 2 ++ .../select-box-kit/components/select-box-kit.js.es6 | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/components/edit-category-security.js.es6 b/app/assets/javascripts/discourse/components/edit-category-security.js.es6 index 05b1f025155..83d658564d9 100644 --- a/app/assets/javascripts/discourse/components/edit-category-security.js.es6 +++ b/app/assets/javascripts/discourse/components/edit-category-security.js.es6 @@ -20,6 +20,8 @@ export default buildCategoryPanel('security', { permission: PermissionType.create({ id: parseInt(id) }) }); } + + this.set('selectedGroup', this.get('category.availableGroups.firstObject')); }, removePermission(permission) { diff --git a/app/assets/javascripts/select-box-kit/components/select-box-kit.js.es6 b/app/assets/javascripts/select-box-kit/components/select-box-kit.js.es6 index 6247aea505c..486b39bd701 100644 --- a/app/assets/javascripts/select-box-kit/components/select-box-kit.js.es6 +++ b/app/assets/javascripts/select-box-kit/components/select-box-kit.js.es6 @@ -481,12 +481,13 @@ export default Ember.Component.extend(UtilsMixin, DomHelpersMixin, KeyboardMixin const none = isNone(this.get("none")); const emptyValue = isEmpty(this.get("value")); - const notEmptyContent = !isEmpty(this.get("content")); - if (none && emptyValue && notEmptyContent) { + if (none && emptyValue) { Ember.run.scheduleOnce("sync", () => { - const firstValue = this.get(`content.0.${this.get("valueAttribute")}`); - this.set("value", firstValue); + if (!isEmpty(this.get("computedContent"))) { + const firstValue = this.get("computedContent.firstObject.value"); + this.set("value", firstValue); + } }); } }