tbleckert / react-select-search

⚡️ Lightweight select component for React
https://react-select-search.vercel.app
MIT License
679 stars 147 forks source link

Keeping data not in search #18

Open anavgagneja opened 7 years ago

anavgagneja commented 7 years ago

Is it possible for the user to enter customized data? For example if they're typing and the option they're looking for is not in the selection box, then they can still type it in. This way it could be used as more of a search box with suggestions from the selection rather than the other way around.

tbleckert commented 7 years ago

Hi and sorry for slow answer, I'm partly having a summer break.

It's not currently possible but it sounds like a really good idea. I think a new property like "renderOptions" would be perfect for this. Currently, when the search field changes, we internally call getNewOptionsList. It does a fussy search on the options list provided when mounting the component. In addition to this, we could call renderOptions, giving the parent component a chance to provide a new list of options based on the search value.

Feel free to submit a PR if you have the time, always appreciated. If not, I could probably look into it in a month or so.

anavgagneja commented 7 years ago

Do you think it would work if I just add value at the top of the 'foundOptions' list in getNewOptionsList when there is no exact match?

tbleckert commented 6 years ago

@anavgagneja Yes, that would work but we wouldn't be able to control it in a different manner from the rest of the options.

I think the best solution for this would be to add a new property; customEntries: PropTypes.bool . If true, we display the value you write att the top of the list of options. In the renderOption method we need to know if it's a custom value or not. That way we can display it differently.

DDushkin commented 5 years ago

Hi, is there any updates with this feature? Cause I have the same problem, I have a list of last 15 users that I comunicated with and I can search them by name or email, but if I havent comunicated with someone and I want to type his email? For now it doesnt work this way. I will appriciate if you will add such feature

tbleckert commented 5 years ago

@DDushkin I haven't had much free time lately but this is a feature that is planned to be added. Hopefully sooner than later. Thanks for showing interest in the feature