mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 11:23:25 +08:00
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) {
|
||||
if (!value || !value.length) {
|
||||
if (!Ember.isPresent(value)) {
|
||||
if (!this.validateSelect(this.selectKit.highlighted)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -169,7 +169,7 @@ export default function selectKit(selector) {
|
|||
},
|
||||
|
||||
async selectRowByName(name) {
|
||||
await selectKitSelectRowByValue(name, selector);
|
||||
await selectKitSelectRowByName(name, selector);
|
||||
},
|
||||
|
||||
async selectNoneRow() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user