Skip to content

Commit

Permalink
Merge pull request #101 from indec-it/fix/formatOnChangeAndFirstProps
Browse files Browse the repository at this point in the history
fix: first onchange of props and format value
  • Loading branch information
maximilianoforlenza authored Feb 10, 2023
2 parents 7e0998b + 726b46d commit 6b2b7a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@indec/react-commons",
"version": "5.6.0",
"version": "5.6.1",
"description": "Common reactjs components for apps",
"private": false,
"main": "index.js",
Expand Down
10 changes: 7 additions & 3 deletions src/components/DatePicker/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ const DatePicker = ({
yearRange,
...props
}) => {
const handleChange = newValue => form?.setFieldValue(field.name, newValue)
|| onChange({target: {id: name, value: newValue}});
const handleChange = newValue => {
const dateToISOString = newValue.toISOString();
return onChange
? onChange({target: {id: name, value: dateToISOString}})
: form.setFieldValue(field.name, dateToISOString);
};
const customHeader = isCustomHeader
? {
renderCustomHeader: datePickerProps => (
Expand Down Expand Up @@ -110,7 +114,7 @@ DatePicker.defaultProps = {
variant: undefined,
isDisabled: false,
isCustomHeader: false,
onChange: () => {},
onChange: undefined,
form: undefined,
field: undefined,
selectsStart: false,
Expand Down

0 comments on commit 6b2b7a5

Please sign in to comment.