react-select-plus icon indicating copy to clipboard operation
react-select-plus copied to clipboard

Add option to show new creatable item as first or last option

Open Stenerson opened this issue 8 years ago • 7 comments

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!

Stenerson avatar Dec 15 '16 17:12 Stenerson

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.

TrevorBurnham avatar Dec 15 '16 18:12 TrevorBurnham

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. 🤔

Stenerson avatar Dec 15 '16 18:12 Stenerson

I hear you.

TrevorBurnham avatar Dec 15 '16 18:12 TrevorBurnham

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.

dhiraj2602 avatar Dec 23 '16 09:12 dhiraj2602

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.

Stenerson avatar Dec 23 '16 14:12 Stenerson

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 avatar Jan 04 '17 07:01 dhiraj2602

@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

Stenerson avatar Jan 04 '17 13:01 Stenerson