JedWatson / react-select

The Select Component for React.js
https://react-select.com/
MIT License
27.57k stars 4.12k forks source link

React select `Create "New Option"` does not show up when using `getOptionLabel` and `getOptionValue` #5799

Open arunbs12 opened 11 months ago

arunbs12 commented 11 months ago

Hello React Select Team,

I'm using react-select/creatable to create new options, when user enters new key options. Also i have getOptionLabel and getOptionValue to show and accept different value other than label and value coming from colourOptions array

<CreatableSelect classNamePrefix="select" onCreateOption={(val) => handleCreate(val)} name="color" getOptionLabel={(option) => option._id || ""} getOptionValue={(option) => option._id || ""} options={colourOptions} />

The problem is, i'm unable to see Create "New Option" as an option to create the dropdown value, Instead i'm seeing a blank row without the text.

Untitled

I have created a working flow for this issue ( Code Sandbox Link ).

Please let me know what fixes do we have for this issue. Thanks

zulmarij commented 10 months ago

You can add a condition in getOptionLabel image