FIX: ensures select-kit can select a row with 0 as value (#8955)
This commit is contained in:
parent
e1e74abd4f
commit
42bda52486
|
@ -41,7 +41,7 @@ export default SelectKitComponent.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
select(value, item) {
|
select(value, item) {
|
||||||
if (!value || !value.length) {
|
if (!Ember.isPresent(value)) {
|
||||||
if (!this.validateSelect(this.selectKit.highlighted)) {
|
if (!this.validateSelect(this.selectKit.highlighted)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -421,8 +421,8 @@ export default Component.extend(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.singleSelect) {
|
if (this.singleSelect) {
|
||||||
value = value.firstObject || null;
|
value = Ember.isPresent(value.firstObject) ? value.firstObject : null;
|
||||||
items = items.firstObject || null;
|
items = Ember.isPresent(items.firstObject) ? items.firstObject : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._boundaryActionHandler("onChange", value, items);
|
this._boundaryActionHandler("onChange", value, items);
|
||||||
|
@ -703,7 +703,7 @@ export default Component.extend(
|
||||||
},
|
},
|
||||||
|
|
||||||
select(value, item) {
|
select(value, item) {
|
||||||
if (!value) {
|
if (!Ember.isPresent(value)) {
|
||||||
if (!this.validateSelect(this.selectKit.highlighted)) {
|
if (!this.validateSelect(this.selectKit.highlighted)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,3 +215,26 @@ componentTest("content is a basic array", {
|
||||||
assert.equal(this.value, null);
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -169,7 +169,7 @@ export default function selectKit(selector) {
|
||||||
},
|
},
|
||||||
|
|
||||||
async selectRowByName(name) {
|
async selectRowByName(name) {
|
||||||
await selectKitSelectRowByValue(name, selector);
|
await selectKitSelectRowByName(name, selector);
|
||||||
},
|
},
|
||||||
|
|
||||||
async selectNoneRow() {
|
async selectNoneRow() {
|
||||||
|
|
Loading…
Reference in New Issue