react-select-plus
react-select-plus copied to clipboard
Add option to show new creatable item as first or last option
Hello, I'm not sure what your general policy is for making changes to react-select-plus that are not already merged upstream into react-select but I thought I'd try anyway! 😎
Sometimes I'd like to discourage my users from creating a new option without at least looking through the list for similar options. In this case, I'd like the new "creatable" option to be last, rather than first.
I created a PR in react-select (JedWatson/react-select#1436) for this but I'm also using react-select-plus and it would be very useful for me to have it here.
The key change is adding a boolean prop to Creatable
and use either unshift
as it's currently doing or use push
based on the prop here.
if (showNewOptionAtTop) {
filteredOptions.unshift(this._createPlaceholderOption);
} else {
filteredOptions.push(this._createPlaceholderOption);
}
Please let me know what you think. I'd be happy to fork and create a PR but I don't want to duplicate my changes here if you'd rather wait for them to merge it upstream.
Thanks!
Generally I wait to see what happens in the upstream project first, so I'll keep an eye on https://github.com/JedWatson/react-select/pull/1436.
10-4 Thanks @TrevorBurnham
react-select is so good and so popular but issues and PRs have been piling up as Jed is busy with other projects. I'm not sure what our best approach is as a community right now. 🤔
I hear you.
When are you planning to add the allowCreate option for the new release? I dont want to play much with the code so that I can be in sync with your repo.
I'm using the Creatable HOC in the currently released version and it works great. This issue is just to add an option to have the new option at the bottom of the list. Today it gets unshift-ed into the list as the first item.
Creatable HOC is supported in the current version of React-select but I am using React-Select-Plus in which it is not supported in the latest version (1.0.0) as of now. Sorry if I am wrong, but kind of using 2 types of plugin because of the same issue.
@dhiraj2602, What I was intending to say is that I'm using React-Select-Plus and Createable is indeed supported in 1.0.0-rc.1.patch3 which is the latest version.
See Pull #42