select icon indicating copy to clipboard operation
select copied to clipboard

Value property must be unique / incorrect option passed to onSelect

Open peterlacko opened this issue 3 years ago • 0 comments

Demo: https://codesandbox.io/s/exciting-bird-x7m1kf?file=/src/App.js

Steps to reproduce:

  1. Click to input, dropdown opens;
  2. Click on first option;
  3. Click to input again;
  4. Click on second option;
  5. Observe console output

Expected behavior: After first click, option with 'key: "id1"' should be passed to onSelect. After second click, option with 'key: "id2"' should be passed to onSelect

Actual behavior: Same option is passed to onSelect (id3) regardless which option I select.

Comment: It's not stated anywhere that value prop must be unique, which in many cases is not satisfying - movies, companies, books etc. can have same name but unique ID. In my case, same values might have highlighted different parts of string - I can not use options prop. I also can not pass id to value, since I need backfill.

One possible solution would be to keep uniqueness only to keys. Other (which will solve only my case) to do backfill with different prop - title, label or something else and fill it with value as a backup.

peterlacko avatar Nov 24 '22 17:11 peterlacko