downshift
downshift copied to clipboard
[BUG] Passing copy of object instead of object creates multiplication of selected items
Version: 6.1.7
Problem description: When I provide the a copy of the selectedItems object, like this:
selectedThings.map((x) => {
return { value: x.value, label: x.label };
})
I start having weird behaviour: When trying to remove one selection, i multiply the selections instead
How to reproduce The easiest way to reproduce is to modify it in this example: https://github.com/downshift-js/downshift-examples/blob/master/src/downshift/ordered-examples/05-multi-create.js
And then replace the line 289 with this:
setSelectedItems(selectedItems.map(x=>{return{value:x.value,label:x.label}}))
Just after that, you can add an item and try to remove it by using the keyboard or the mouse in the pop in
Ok but... why would you need a copy of the object? Well, i'm actually getting from DB objects that don't have label and value properties, so i'm just creating a new object mapping the right properties.
Suggested solution: I have no idea :S, took me at least 6 hours just to find out the problem
Extra For some reason, on that example deleting using the tags kind of work, is the pop in list the one giving issues