diff --git a/src/atoms/dataEntry/DateInput/DateInput.js b/src/atoms/dataEntry/DateInput/DateInput.js index 991b8b27..f506320c 100644 --- a/src/atoms/dataEntry/DateInput/DateInput.js +++ b/src/atoms/dataEntry/DateInput/DateInput.js @@ -75,6 +75,17 @@ class DateInput extends React.Component { } }; + onBlur = () => { + const { withTime } = this.props; + const { textValue } = this.state; + + const luxonValue = utils.fromViewFormatToLuxon(textValue, withTime); + + if (luxonValue && !luxonValue.isValid) { + this.setState({ textValue: utils.fromISOToViewFormat(this.props.value, withTime) }); + } + } + onChangeDate = (selected: Date) => { const { withTime, value } = this.props; @@ -132,7 +143,7 @@ class DateInput extends React.Component { { ...rest } > - + diff --git a/src/atoms/dataEntry/DateInput/DateInputValue.js b/src/atoms/dataEntry/DateInput/DateInputValue.js index 7e525ec8..f4a5138b 100644 --- a/src/atoms/dataEntry/DateInput/DateInputValue.js +++ b/src/atoms/dataEntry/DateInput/DateInputValue.js @@ -7,6 +7,7 @@ import { Input } from '../Input'; type DateInputValueProps = {| onChange: (value: Object) => void, + onBlur: () => void, value: ?string, mask: string, |};