Creatable: onNewOptionClick doesn't fire, doesn't seem to be present
newOptionCreator fires every keystroke but I can't find the onNewOptionClick referenced in the docs
The NPM package doesn't seem to have this function
There should be a way to hook into the creation process before the option is added to the select, I'd rather run the new option up through the store and down into the component than add it directly into the component
I've got the same problem. @drsloth This functionality was pulled in https://github.com/JedWatson/react-select/pull/1364, you can download the master branch and compile it.
I'm using master, but the onNewOptionClick does not fire for me...am I missing something? I'm trying to trigger a modal when a user is trying to create a new option.
No it's not totally implemented yet. The hook is present here: https://github.com/JedWatson/react-select/blob/master/src/Creatable.js#L41
but not here: https://github.com/JedWatson/react-select/blob/master/dist/react-select.js#L306
or here: https://github.com/JedWatson/react-select/blob/master/lib/Creatable.js#L51
On Fri, Dec 23, 2016 at 9:50 AM, Eamon Penland [email protected] wrote:
I'm using master, but the onNewOptionClick does not fire for me...am I missing something?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/JedWatson/react-select/issues/1398#issuecomment-269008492, or mute the thread https://github.com/notifications/unsubscribe-auth/ALhvt8k82GS7as4eU6U5bQJudSwTkkdRks5rK-2-gaJpZM4LAXYc .
Even I am facing this issue. Not able to fire newOptionCreator
i've been doing a somewhat janky workaround
assuming you have simpleValue={true}, so your results are passed as a comma-delimited string:
const _onChange = (newTags) => {
const { currentTags } = props // tags that were already applied
const newTagsArray = newTags.split(',')
// find which value is new
const [alteredValue] = newTagsArray.filter(tag => !currentTags.includes(tag))
// fetch whatever array we're keeping our options in
// turn it into an array of strings
const allTagLabels = props.tagOptions.map(t => t.label)
if (allTagLabels.includes(alteredValue)) {
console.log(`${alteredValue} already existed`)
} else {
console.log(`${alteredValue} was created`)
}
}
then just pass this as your onChange
<Select.Creatable
simpleValue
onChange={_onChange}
...props
/>
@hegdeas It seem to work for me!!
Hello -
In an effort to sustain the react-select project going forward, we're closing old issues / pull requests.
We understand this might be inconvenient but in the best interest of supporting the broader community we have to direct our limited efforts to maintain the latest version.
If you feel this issue / pull request is still relevant and you'd like us to review it, please leave a comment and we'll do our best to get back to you.