downshift icon indicating copy to clipboard operation
downshift copied to clipboard

[BUG] Passing copy of object instead of object creates multiplication of selected items

Open lveillard opened this issue 3 years ago • 0 comments

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 image

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

lveillard avatar Jan 23 '22 23:01 lveillard