diff --git a/app/assets/javascripts/select-kit/components/multi-select.js.es6 b/app/assets/javascripts/select-kit/components/multi-select.js.es6 index dd24a6b9175..2bb727caf6c 100644 --- a/app/assets/javascripts/select-kit/components/multi-select.js.es6 +++ b/app/assets/javascripts/select-kit/components/multi-select.js.es6 @@ -41,7 +41,7 @@ export default SelectKitComponent.extend({ }, select(value, item) { - if (!value || !value.length) { + if (!Ember.isPresent(value)) { if (!this.validateSelect(this.selectKit.highlighted)) { return; } diff --git a/app/assets/javascripts/select-kit/components/select-kit.js.es6 b/app/assets/javascripts/select-kit/components/select-kit.js.es6 index 4f474009ec6..4b1f896ff84 100644 --- a/app/assets/javascripts/select-kit/components/select-kit.js.es6 +++ b/app/assets/javascripts/select-kit/components/select-kit.js.es6 @@ -421,8 +421,8 @@ export default Component.extend( } if (this.singleSelect) { - value = value.firstObject || null; - items = items.firstObject || null; + value = Ember.isPresent(value.firstObject) ? value.firstObject : null; + items = Ember.isPresent(items.firstObject) ? items.firstObject : null; } this._boundaryActionHandler("onChange", value, items); @@ -703,7 +703,7 @@ export default Component.extend( }, select(value, item) { - if (!value) { + if (!Ember.isPresent(value)) { if (!this.validateSelect(this.selectKit.highlighted)) { return; } diff --git a/test/javascripts/components/select-kit/single-select-test.js.es6 b/test/javascripts/components/select-kit/single-select-test.js.es6 index 166660adf7a..42f058a5862 100644 --- a/test/javascripts/components/select-kit/single-select-test.js.es6 +++ b/test/javascripts/components/select-kit/single-select-test.js.es6 @@ -215,3 +215,26 @@ componentTest("content is a basic array", { assert.equal(this.value, null); } }); + +componentTest("selected value can be 0", { + template: template(), + + beforeEach() { + setDefaultState(this, { + value: 1, + content: [ + { id: 0, name: "foo" }, + { id: 1, name: "bar" } + ] + }); + }, + + async test(assert) { + assert.equal(this.subject.header().value(), 1); + + await this.subject.expand(); + await this.subject.selectRowByValue(0); + + assert.equal(this.subject.header().value(), 0); + } +}); diff --git a/test/javascripts/helpers/select-kit-helper.js.es6 b/test/javascripts/helpers/select-kit-helper.js.es6 index a6ada50b9b4..c103c4371c5 100644 --- a/test/javascripts/helpers/select-kit-helper.js.es6 +++ b/test/javascripts/helpers/select-kit-helper.js.es6 @@ -169,7 +169,7 @@ export default function selectKit(selector) { }, async selectRowByName(name) { - await selectKitSelectRowByValue(name, selector); + await selectKitSelectRowByName(name, selector); }, async selectNoneRow() {