mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
FIX: value-list choices when removing a value
Fixes an issue where choices were broken when removing an item from the value-list component. Adds test case for this scenario.
This commit is contained in:
@ -73,11 +73,10 @@ export default Component.extend({
|
|||||||
_removeValue(value) {
|
_removeValue(value) {
|
||||||
this.collection.removeObject(value);
|
this.collection.removeObject(value);
|
||||||
|
|
||||||
const item = { id: value, name: value };
|
|
||||||
if (this.choices) {
|
if (this.choices) {
|
||||||
this.choices.addObject(item);
|
this.set("choices", this.choices.push(value).uniq());
|
||||||
} else {
|
} else {
|
||||||
this.set("choices", makeArray(item));
|
this.set("choices", makeArray(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
this._saveValues();
|
this._saveValues();
|
||||||
|
@ -45,6 +45,14 @@ componentTest("removing a value", {
|
|||||||
);
|
);
|
||||||
|
|
||||||
assert.equal(this.values, "osama", "it removes the expected value");
|
assert.equal(this.values, "osama", "it removes the expected value");
|
||||||
|
|
||||||
|
await selectKit().expand();
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
find(".select-kit-collection li.select-kit-row span.name")[0]
|
||||||
|
.innerText === "vinkas",
|
||||||
|
"it adds the removed value to choices"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user