Skip to content

Commit

Permalink
added clearvalue functionality to State example
Browse files Browse the repository at this point in the history
  • Loading branch information
gwyneplaine committed Jan 4, 2018
1 parent e6499a4 commit 1c20dc2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion examples/src/components/States.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ var StatesField = createClass({
rtl: false,
};
},
clearValue (e) {
this.select.setInputValue('');
},
switchCountry (e) {
var newCountry = e.target.value;
this.setState({
Expand Down Expand Up @@ -54,7 +57,9 @@ var StatesField = createClass({
<h3 className="section-heading">{this.props.label} <a href="https://github.com/JedWatson/react-select/tree/master/examples/src/components/States.js">(Source)</a></h3>
<Select
id="state-select"
ref="stateSelect"
ref={(ref) => { this.select = ref; }}
onBlurResetsInput={false}
onSelectResetsInput={false}
autoFocus
options={options}
simpleValue
Expand All @@ -68,6 +73,8 @@ var StatesField = createClass({
searchable={this.state.searchable}
/>
<button style={{ marginTop: '15px' }} type="button" onClick={this.focusStateSelect}>Focus Select</button>
<button style={{ marginTop: '15px' }} type="button" onClick={this.clearValue}>Clear Value</button>

<div className="checkbox-list">

<label className="checkbox">
Expand Down
2 changes: 1 addition & 1 deletion test/Async-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ describe('Async', () => {
});

it('should not update options on componentWillReceiveProps', () => {
const props = {options: []};
const props = { options: [] };
createControl(props);

const setStateStub = sinon.stub(asyncInstance, 'setState');
Expand Down

0 comments on commit 1c20dc2

Please sign in to comment.