Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1394 #1395

Merged
merged 4 commits into from
May 17, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ const Select = React.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 == null || this.props.value === 0 || this.props.multi && !this.props.value.length || this.props.disabled || this.props.isLoading) return;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and what about this.props.value === 0?
sometimes we have to use zero value and clear button is not displayed (

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I guess we could remove this condition, and not display the clear button only when this.props.value is null or undefined

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src and tests updated 😉

return (
<span className="Select-clear-zone" title={this.props.multi ? this.props.clearAllText : this.props.clearValueText}
aria-label={this.props.multi ? this.props.clearAllText : this.props.clearValueText}
Expand Down
5 changes: 5 additions & 0 deletions test/Select-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,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