Skip to content

Creatable doesn't get new value from onInputChange() prop #2056

@cscholze

Description

@cscholze

The onInputChange() handler does not return the modified value. I've included a plunker to demonstrate the issue.

The issue is that this.props.onInputChange does not mutate input, thus this.inputValue is always input and the method always returns the unmodified input.
https://github.com/JedWatson/react-select/blob/master/src/Creatable.js#L172

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;
},

It appears that there a couple of related issues and PRs already open, but either they have not been reviewed or the submitter has not updated. I also don't think that the open PRs offer the best solution, nor solve it completely, so I felt it best to open a new issue and PR. Either way, we are trying to use this library in a project and would like to see this corrected as soon as possible.

Opened PR #2057

Related open Issues
#1597
#1506
#1349

Related open PRs
#1363
#1411

@JedWatson

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions