handle when a date/datetime field is updated to empty

This commit is contained in:
Shawn Erquhart 2017-11-27 22:33:54 -05:00
parent a7ad6d570e
commit 0caae558f9

View File

@ -18,10 +18,13 @@ export default class DateControl extends React.Component {
}
handleChange = datetime => {
const newValue = this.format
? moment(datetime).format(this.format)
: datetime;
this.props.onChange(newValue);
const { onChange } = this.props;
if (!this.format || datetime === '') {
onChange(datetime);
} else {
const formattedValue = moment(datetime).format(this.format);
onChange(formattedValue);
}
};
render() {