handle when a date/datetime field is updated to empty
This commit is contained in:
parent
a7ad6d570e
commit
0caae558f9
@ -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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user