fix(date): allow default value to Date field (#3740)
This commit is contained in:
parent
7cc4c89539
commit
8ab2a6036b
@ -50,7 +50,14 @@ export default class DateControl extends React.Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getDefaultValue() {
|
||||||
|
const { field } = this.props;
|
||||||
|
const defaultValue = field.get('default');
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
formats = this.getFormats();
|
formats = this.getFormats();
|
||||||
|
defaultValue = this.getDefaultValue();
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
warnDeprecated();
|
warnDeprecated();
|
||||||
@ -60,9 +67,9 @@ export default class DateControl extends React.Component {
|
|||||||
* Set the current date as default value if no default value is provided. An
|
* Set the current date as default value if no default value is provided. An
|
||||||
* empty string means the value is intentionally blank.
|
* empty string means the value is intentionally blank.
|
||||||
*/
|
*/
|
||||||
if (!value && value !== '') {
|
if (value === undefined) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.handleChange(new Date());
|
this.handleChange(this.defaultValue === undefined ? new Date() : this.defaultValue);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user