Skip to content

A platform for community discussion. Free, open, simple.

FIX: value-list choices when removing a value

Penar Musaraj89d9704194c8
diff --git a/app/assets/javascripts/admin/components/value-list.js.es6 b/app/assets/javascripts/admin/components/value-list.js.es6
index 99f1cc00d44..fe79b686ce3 100644
--- a/app/assets/javascripts/admin/components/value-list.js.es6
+++ b/app/assets/javascripts/admin/components/value-list.js.es6
@@ -73,11 +73,10 @@ export default Component.extend({
_removeValue(value) {
this.collection.removeObject(value);
- const item = { id: value, name: value };
if (this.choices) {
- this.choices.addObject(item);
+ this.set("choices", this.choices.push(value).uniq());
} else {
- this.set("choices", makeArray(item));
+ this.set("choices", makeArray(value));
}
this._saveValues();
diff --git a/test/javascripts/components/value-list-test.js.es6 b/test/javascripts/components/value-list-test.js.es6
index 0c605ef0761..15365e22258 100644
--- a/test/javascripts/components/value-list-test.js.es6
+++ b/test/javascripts/components/value-list-test.js.es6
@@ -45,6 +45,14 @@ componentTest("removing a 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"
+ );
}
});