-
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
#658 Allow Create functionality [WIP] #660
Conversation
Updating the react select
Pending: Test Cases are failing need to fix that
Thanks, I'm testing this out... the newOptionCreator missing is a big problem for us. |
<Select | ||
allowCreate={this.props.allowCreate} | ||
value={this.state.value} | ||
multi={true} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally preferred that boolean props that are true don't have an explicit declaration. remove the ={true}
e.g. https://github.com/JedWatson/react-select/blob/master/examples/src/components/NumericSelect.js#L66
Great progress :) |
Looking forward to this! |
^ mandatory +1 |
+1 |
1 similar comment
👍 |
👍 this no allowCreate is a huge problem for us |
This was a show stopper for us, but there is a workaround. For those of you that need allowCreate today - you can just use filterOptions and add an option {label: |
👍 |
- Custom style overrides - single and multi examples - Downgraded sass naming convention errors to warnings until we can do inline/file based rules/exclusions - Added spacing between example components - `allowCreate` dependant on JedWatson/react-select#660
- Custom style overrides - single and multi examples - Downgraded sass naming convention errors to warnings until we can do inline/file based rules/exclusions - Added spacing between example components - `allowCreate` dependant on JedWatson/react-select#660
- Custom style overrides - single and multi examples and tests - Downgraded sass naming convention errors to warnings until we can do inline/file based rules/exclusions - Added spacing between example components - `allowCreate` dependant on JedWatson/react-select#660
- Custom style overrides - single and multi examples and tests - Downgraded sass naming convention errors to warnings until we can do inline/file based rules/exclusions - Added spacing between example components - `allowCreate` dependant on JedWatson/react-select#660
- Custom style overrides - single and multi examples and tests - Downgraded sass naming convention errors to warnings until we can do inline/file based rules/exclusions - Added spacing between example components and removed unnecessary `<div>`s - `allowCreate` dependant on JedWatson/react-select#660 - Removed unnecessary box shadow length properties
- Custom style overrides - single and multi examples and tests - Downgraded sass naming convention errors to warnings until we can do inline/file based rules/exclusions - Added spacing between example components and removed unnecessary `<div>`s - `allowCreate` dependant on JedWatson/react-select#660 - Removed unnecessary box shadow length properties
- Custom style overrides - single and multi examples and tests - Downgraded sass naming convention errors to warnings until we can do inline/file based rules/exclusions - Added spacing between example components and removed unnecessary `<div>`s - `allowCreate` dependant on JedWatson/react-select#660 - Removed unnecessary box shadow length properties
- Custom style overrides - single and multi examples and tests - Downgraded sass naming convention errors to warnings until we can do inline/file based rules/exclusions - Added spacing between example components and removed unnecessary `<div>`s - `allowCreate` dependant on JedWatson/react-select#660 - Removed unnecessary box shadow length properties
- Custom style overrides - single and multi examples and tests - Downgraded sass naming convention errors to warnings until we can do inline/file based rules/exclusions - Added spacing between example components and removed unnecessary `<div>`s - `allowCreate` dependant on JedWatson/react-select#660 - Removed unnecessary box shadow length properties
👍 |
Looking forward to this being implemented in the new version. Thanks for your efforts guys! |
Definitely excited about this 💯 |
Is this on the roadmap to be merged soon? Looking forward to using it in production! 👍 |
+1 |
1 similar comment
+1 |
Thanks @mitani for the workaround! For anyone looking for more details on said, here's a sample commit. I like this solution as it grants more flexibility, and works for Incidentally this PR is getting pretty old. I tried to fork & rebase but was a bit out of my league. I have to ask: is the only reason this hasn't been merged cosmetic concerns (aligning comments, If it is rebase + style, I'd be happy to take a pass this week. If it's more, let us know |
Thank you, @lefnire and @mitani ! filterOptions = (options, filter, values) => {
// Filter already selected values
let filteredOptions = options.filter(option => {
return !(values.includes(option));
});
// Filter by label
if (filter !== undefined && filter != null && filter.length > 0) {
filteredOptions = filteredOptions.filter(option => {
return RegExp(filter, 'ig').test(option.label);
});
}
// Append Addition option
if (filteredOptions.length == 0) {
filteredOptions.push({
label: <span><strong>Create</strong>: {filter}</span>,
value: filter,
create: true,
});
}
return filteredOptions;
}; |
+1 |
Hey, I also want to add a +1 to this PR. If it is only stylistic changes stopping from this being merged, I can get started on fixing them. We are using an older version of the library (0.9 to be specific) because it has the |
+1 |
Thank you @cema-sp for that ES6 solution! One thing I noticed is that you can add Also if you're rolling with this solution and you want to hide the word Create from showing up once the new label has been added to the selected options, I was able to handle that with some custom css. if (filteredOptions.length === 0 && filter.length > 0) {
filteredOptions.push({
label: <span><strong>Create: </strong>{filter}</span>,
value: filter,
create: true,
});
} .Select-value-label strong {
display: none;
} Successfully using this in place of |
+1 |
https://github.com/mehcode/react-select ^ I have no recollection of what I did but I think I based it off of this PR and did something. It gives me warnings on npm about missing peer dependencies but it does work with React 15.x |
This looks like it has stalled since December - are there only those few little stylistic comments in the PR holding it back? I could quite happily do these if it meant that this would get merged ASAP @omgaz! |
@@ -1047,7 +1047,7 @@ describe('Select', () => { | |||
describe('with allowCreate=true', () => { | |||
|
|||
// TODO: allowCreate hasn't been implemented yet in 1.x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment
THere's also a big missing chunk in an else if (this.props.allowCreate) {}, I'm not sure what vickyonit intended for this. It'd be awesome if someone would look into reviving this :) Thanks @wbecker |
Thanks @vickyonit, this has since been superseded by #1187 which abstracts option creation to a Creatable HoC. |
Fix for following issues:
#658
#586
Tech Changes:
Option
to render the "Add " label field if option is createrenderMenu
to show the newOption
ifallowCreate
in the listAssumptions:
addLabelText
contains{label}
in it.newOptionCreator
always contains the following structure{ value: value, label: value, create: true }