React-Select pre-populating a multiple dropdown adds a blank option to the values. #5093
Unanswered
AlexMachin1997
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone,
Just wanted to say I believe this component is one of the better select components I've used and it has worked great so far however I've come across some weird behaviour and I would like to open up a discussion about.
Issue:
So on a work project I noticed that when pre-populating a "multiple" dropdown with an existing value react-select would render an additional blank option even though that's not apart of the value or the options.
I'm a little confused by this behaviour why would it add an extra blank option with no lable or value to the value ?
Example:
dropdown recieves the following value:
["Site1", "Site2"]
dropdown component performs initial on load action e.g. mapping value to the react-select value e.g.
["Site1", "Site2"]
->[{value: "Site1", label: "Site1"},{label: "Site2", value: "Site2"}]
The dropdown component would show the select values but when it was a multi dropdown it would have a blank even though that doesn't exist in my options or value so it's something to do with the component.
It would be great to hear what other people think about this a I'm a little puzzled why this is happening.
if you would like the components code to see how it works then I can provide that, though for now I'll leave that out.
Thank's,
Alex
Beta Was this translation helpful? Give feedback.
All reactions