Skip to content

Commit

Permalink
Fix #1394 (#1395)
Browse files Browse the repository at this point in the history
* Fix #1394

* Updates following review

* Updates following review by @JedWatson
  • Loading branch information
sgaestel authored and agirton committed May 17, 2017
1 parent 549d20a commit fd19b91
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,8 @@ const Select = createClass({
},

renderClear () {
if (!this.props.clearable || (!this.props.value || this.props.value === 0) || (this.props.multi && !this.props.value.length) || this.props.disabled || this.props.isLoading) return;

if (!this.props.clearable || this.props.value === undefined || this.props.value === null || this.props.multi && !this.props.value.length || this.props.disabled || this.props.isLoading) return;
const clear = this.props.clearRenderer();

return (
Expand Down
10 changes: 10 additions & 0 deletions test/Select-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,11 @@ describe('Select', () => {
expect(onChange, 'was called with', 0);
});

it('displays the X button for 0 value', () => {
wrapper.setPropsForChild({ value: 0 });
expect(ReactDOM.findDOMNode(instance).querySelector('.Select-clear'), 'not to equal', undefined);
});

describe('with multi=true', () => {

beforeEach(() => {
Expand Down Expand Up @@ -962,6 +967,11 @@ describe('Select', () => {
'to have text', 'No');
});

it('displays the X button for false value', () => {
wrapper.setPropsForChild({ value: false });
expect(ReactDOM.findDOMNode(instance).querySelector('.Select-clear'), 'not to equal', undefined);
});

describe('with multi=true', () => {

beforeEach(() => {
Expand Down

0 comments on commit fd19b91

Please sign in to comment.