Creatable does not invoke onInputChange prop
The Creatable class does not run onInputChange when designated as a prop.
I noticed something similar with AsyncCreatable. Since onInputChange is called as a prop directly in it's source, you can't overwrite it when calling a parent Select. I also noticed that onInputChange isn't invoked when blurring a select with an input value, even when onBlurResetsInput is set to true. Seems like it should, because refocusing the input then gives you a menu with the last input you typed.
I was trying to use this event to catch when a user pastes in a comma separated string of values. Pretty unfortunate that it doesn't work as documented...
I am seeing this issue as well for the Creatable component. The bug lies on these lines in that component:
onInputChange (input) {
const { onInputChange } = this.props;
if (onInputChange) {
onInputChange(input);
}
// This value may be needed in between Select mounts (when this.select is null)
this.inputValue = input;
}
Even though onInputChange() is called, the value is not returned. When I just use the Select component I am able to apply a masking function, whereas when using the Creatable component, that masking function value is never returned from the Creatable onInputChange call to the Select component. The function passed in as a prop is called, but the value is never returned up the call stack.
The correct code would look like this:
onInputChange (input) {
const { onInputChange } = this.props;
// This value may be needed in between Select mounts (when this.select is null)
this.inputValue = input;
if (onInputChange) {
return onInputChange(input);
}
}
cc: @JedWatson
Do we have any update on this? Creatable is still unable to modify text with the onInputChange prop.
@mhubenthal Your suggested fix will not work. It must also set this.input to the return value of this.props.onInputChange() else the resulting label created will include the last typed character.
I believe this can be closed now because #2057 has been merged, could everyone please confirm that it solves the problem correctly for their use-case? and continue discussion on #2056 if not.
Thanks!