Skip to content

Commit

Permalink
Merge pull request #782 from bindoon/fix-set-undefined-value
Browse files Browse the repository at this point in the history
Fix(NumberPicker): set null to reset value
  • Loading branch information
youluna authored Jun 13, 2019
2 parents ba8083c + e4220c6 commit 41ae904
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/number-picker/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ class NumberPicker extends React.Component {

componentWillReceiveProps(nextProps) {
if ('value' in nextProps) {
const value = nextProps.value;
this.setState({
value: nextProps.value === undefined ? '' : nextProps.value,
value: value === undefined || value === null ? '' : value,
});
}
}
Expand Down
3 changes: 3 additions & 0 deletions test/number-picker/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,9 @@ describe('number-picker', () => {
wrapper.setProps({ value: undefined });
assert(wrapper.find('input').prop('value') === '');

wrapper.setProps({ value: null });
assert(wrapper.find('input').prop('value') === '');

done();
});
});
Expand Down

0 comments on commit 41ae904

Please sign in to comment.