Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-select",
"version": "1.0.0-beta13",
"name": "react-select-hydrationlabs",
"version": "1.0.0",
"description": "A Select control built with and for ReactJS",
"main": "lib/Select.js",
"style": "dist/react-select.min.css",
Expand Down
14 changes: 10 additions & 4 deletions src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const Select = React.createClass({
resetValue: React.PropTypes.any, // value to use when you clear the control
scrollMenuIntoView: React.PropTypes.bool, // boolean to enable the viewport to shift so that the full menu fully visible when engaged
searchable: React.PropTypes.bool, // whether to enable searching feature or not
searchText: React.PropTypes.string,
simpleValue: React.PropTypes.bool, // pass the value to onChange as a simple value (legacy pre 1.0 mode), defaults to false
style: React.PropTypes.object, // optional style to apply to the control
tabIndex: React.PropTypes.string, // optional tab index of the control
Expand Down Expand Up @@ -186,6 +187,11 @@ const Select = React.createClass({
this.hasScrolledToOption = false;
}


if ((prevState.inputValue !== this.state.inputValue || prevProps.searchText !== this.props.searchText) && this.props.onInputChange) {
this.props.onInputChange(this.props.searchText === prevProps.searchText ? this.state.inputValue : this.props.searchText);
}

if (this._scrollToFocusedOptionOnUpdate && this.refs.focused && this.refs.menu) {
this._scrollToFocusedOptionOnUpdate = false;
var focusedDOM = ReactDOM.findDOMNode(this.refs.focused);
Expand Down Expand Up @@ -386,7 +392,7 @@ const Select = React.createClass({
if (this.props.disabled) return;
switch (event.keyCode) {
case 8: // backspace
if (!this.state.inputValue && this.props.backspaceRemoves) {
if (!(this.state.inputValue || this.props.searchText) && this.props.backspaceRemoves) {
event.preventDefault();
this.popValue();
}
Expand Down Expand Up @@ -608,7 +614,7 @@ const Select = React.createClass({
let renderLabel = this.props.valueRenderer || this.getOptionLabel;
let ValueComponent = this.props.valueComponent;
if (!valueArray.length) {
return !this.state.inputValue ? <div className="Select-placeholder">{this.props.placeholder}</div> : null;
return !(this.state.inputValue || this.props.searchText) ? <div className="Select-placeholder">{this.props.placeholder}</div> : null;
}
let onClick = this.props.onValueClick ? this.handleValueClick : null;
if (this.props.multi) {
Expand Down Expand Up @@ -668,7 +674,7 @@ const Select = React.createClass({
minWidth="5"
ref="input"
required={this.state.required}
value={this.state.inputValue}
value={this.props.searchText || this.state.inputValue}
/>
);
}
Expand All @@ -682,7 +688,7 @@ const Select = React.createClass({
onFocus={this.handleInputFocus}
ref="input"
required={this.state.required}
value={this.state.inputValue}
value={this.props.searchText || this.state.inputValue}
/>
</div>
);
Expand Down