-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allowCreate={true} does not work in in 1.0.0 #586
Comments
Is this maybe covered by the "tags mode"? #568 (comment) |
@cgwyllie yes, it's tags mode I was looking for. Seems like it's not yet implemented. What's the recommended version to use with react 0.14? It seems 0.9 is stable, but not compatible with latest react. |
Any updates or ETA's on making this work? Is anyone working on it or should we tackle it? |
+1 |
1 similar comment
+1 |
Same. How far are you on this? I've started looking at the code and I already have partial support for allowCreate on multi/single value. |
+1 |
+1 |
1 similar comment
+1 |
👍 for tags mode in 1.0, and until then please alert in the README that |
Sorry. Can someone enlighten me what's a tags mode? allowCreate={true} is not working me as well. Curious to know whether I am using tags mode or not. |
+1 |
Hey everyone! I figured out a (very) hacky way around this. If you overide filterOptions: function (options, filter, currentValues) {
var filteredOptions = [];
if (filter && filter.length >= 1){ // If a filter is present
_.each(options, function(option){
if (option.value.toLowerCase().trim().indexOf(filter.toLowerCase().trim()) > -1) {
filteredOptions.push(option);
}
});
}
else { // Show everything available that's not already selected if no filter is used
_.each(options, function(option){
if (!_.contains(_.pluck(currentValues, 'value'), option.value)){
filteredOptions.push(option);
}
});
}
// Only display `Add ${filter}` if no other options are available
if (filteredOptions.length == 0 && filter) {
filteredOptions.push({label: `Add ${filter}`, value: filter, create:true});
}
return filteredOptions;
}, And then handleSelectChange: function (value) { // value is an array of values -- I write bad code
_.each(value, function (singleValue) {
if (singleValue.create){
singleValue.create = false;
singleValue.label = singleValue.value.trim();
// I'm using a more complex slugify function here
singleValue.value = singleValue.label.toLowerCase();
}
});
console.log('You\'ve selected:', JSON.stringify(value));
this.setState({ value });
}, Finally, when I define Select, I use the following configuration filterOptions={this.filterOptions}
onChange={this.handleSelectChange} Notice that allowCreate is not used. Notice my underscore dependency. You could eliminate the _.each loops with |
An ES6 implementation of the above: https://gist.github.com/Craga89/5215e0e5079741b856d8 |
+1 |
+1 - It's a bit annoying to see support of 'allowCreate' in the README, and then install the npm, code the example and THEN see things not working. Please prioritize this bug or at least update the README saying that allowCreate isn't supported yet. |
+1 It's really important i don't understand why it still needs to be done... i've spend lot of time figuring out( |
+1 |
Just use last stable release. That's the fix for me. |
If you need native allowCreate, use a version that has it. If you want to use the newest, this bit of code is working for me as a wrapper that you can pass other props into.
|
+1... Figured it out by checking the source and seeing all related to allowCreate commented out. |
I think it would be worth updating the docs explaining that this feature doesn't work in the latest version. Spent more time than I'd like to admit trying to get this to work, finally ended up here, just to find out this is no longer supported (unless you use a previous version). |
Agreed on updating the docs to explain that this feature doesn't work with the 1.0 beta. Is there a native version of this library with allowCreate and react 15 compatibility? :( |
+1 definitely just wasted time by trusting the docs ;) |
What is the latest version of react-select that still has support for allowCreate? |
@francis-li v0.9.1 seems to be the latest version supporting Reference: |
+1 |
4 similar comments
+1 |
+1 |
+1 |
+1 |
By the way, I believe PR #1187 should resolve this issue. Please feel free top give the branch a spin and let me know if you have any concerns or other feedback. 😄 |
This issue no longer exists in the 1.x code (as of PR #1187) and so I'm going to close it! Look for an updated RC with this functionality soon. 😎 |
It still doesn't work with the latest RC, is it normal? |
@mayerwin Are you using the recently added Creatable component? If not, please try it. |
@bvaughn Yes just found out about it in another issue. The documentation was quite misleading as it was somehow saying we should go back to 0.9 to get support for allowCreate, without mentioning at the same time that Creatable provided the now recommended way to achieve the same result. |
@mayerwin Documentation is hard. I think Jed probably wrote the original docs and I tried to update them when I added Creatable. Apparently I missed some spots though. Best thing you could do- if you're willing- would be to submit a docs PR and tag me on it. It would help others like yourself. 😄 |
@bvaughn Done. |
Is
allowCreate={true}
planned to be added, or is it a bug? If latter, when would this be added?The text was updated successfully, but these errors were encountered: