From fd19b91f81d9a6809f41357c3f244af376438771 Mon Sep 17 00:00:00 2001 From: Simon Gaestel Date: Wed, 17 May 2017 18:22:34 +0200 Subject: [PATCH] Fix #1394 (#1395) * Fix #1394 * Updates following review * Updates following review by @JedWatson --- src/Select.js | 3 ++- test/Select-test.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Select.js b/src/Select.js index e4de56176c..20b454e45a 100644 --- a/src/Select.js +++ b/src/Select.js @@ -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 ( diff --git a/test/Select-test.js b/test/Select-test.js index 10a2c6afb1..8cc43a8c1a 100644 --- a/test/Select-test.js +++ b/test/Select-test.js @@ -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(() => { @@ -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(() => {