Skip to content

Commit

Permalink
fix(date-phone): normalize viewValue with date
Browse files Browse the repository at this point in the history
fix(date-phone): normalize viewValue with date
  • Loading branch information
guillaume-chervet committed Jun 4, 2020
2 parents 114d1d0 + e7cfae8 commit 2b25b07
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/Form/Input/date-phone/src/DatePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const DatePhone = props => {
if (value) {
currentViewValue = value.format('YYYY-MM-DD');
} else if (viewValue != null && viewValue != undefined) {
currentViewValue = viewValue;
currentViewValue = viewValue.replace(". ", "-").replace("/", "-").replace(".", "-");
}

return (
Expand Down Expand Up @@ -63,9 +63,11 @@ const defaultProps = {
const handlers = {
onChange: ({ id, name, onChange }) => e => {
const viewValue = e.target.value;
const value = moment(viewValue);

onChange({
value: moment(viewValue),
viewValue,
value,
viewValue: value.format("L"),
name,
id,
});
Expand Down

0 comments on commit 2b25b07

Please sign in to comment.