Skip to content

Commit

Permalink
fix(DateInput): use empty string instead of null for text value
Browse files Browse the repository at this point in the history
  • Loading branch information
zouxuoz committed May 21, 2019
1 parent 9344f1e commit 43d300e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/DateInput/DateInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DateInput extends React.Component<DateInputProps, DateInputState> {
componentDidUpdate(prevProps: DateInputProps) {
const { value, withTime } = this.props;

if (value && value !== prevProps.value) {
if (value !== prevProps.value) {
this.setState({
textValue: utils.fromISOToViewFormat(value, withTime),
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/DateInput/DateInput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe('<DateInnput />', () => {
wrapper.find(Dropdown.Head).simulate('click');

expect(wrapper.find(DatePicker).props().selected).toBeNull();
expect(wrapper.find(Input).props().value).toBeNull();
expect(wrapper.find(Input).props().value).toEqual('');
});


Expand Down
4 changes: 2 additions & 2 deletions src/components/DateInput/DateInput.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export const fromISOToViewFormat = (value: ?string, withTime: ?boolean) => {
if (value.isValid) {
value = value.toFormat(withTime ? DATETIME_FORMAT : DATE_FORMAT);
} else {
value = null;
value = '';
}
} else {
value = null;
value = '';
}

return value;
Expand Down

0 comments on commit 43d300e

Please sign in to comment.