react-select icon indicating copy to clipboard operation
react-select copied to clipboard

With isMulti, not defining a "value" for options allows to pick a first item but not another one

Open 03xb7 opened this issue 5 years ago • 3 comments

Hi, I'd like to report a bug.

https://codesandbox.io/s/mystifying-water-brynv

Despite my options not having a "value" key I can still browse the options and select a first item. Once I did that though, I can't see options for picking a second item. I get the "no options" UI.

I am aware that my code is broken since I should define a value for options but the fact that it's working for the first item selection feels odd.

Best

03xb7 avatar Apr 16 '21 10:04 03xb7

Hello @htulipe,

this is because when the component tries to get a value representation from the option, it gets undefined (default is option.value). Therefore all of your options have the same value and are excluded from the list (because they seem to be selected).

Setting the prop hideSelectedOptions to the value false (its true by default) will show that all options are highlighted as being selected.

Rall3n avatar Apr 16 '21 10:04 Rall3n

Thanks for a quick answer @Rall3n! It makes sense. Not sure if it's a bug per se then. Shall I close ?

03xb7 avatar Apr 16 '21 13:04 03xb7

To anyone facing this issue, you can actually map any option field to value with getOptionValue which solves the issue without changing hideSelectedOptions.

arthurRbr avatar Oct 12 '23 16:10 arthurRbr