From 0000d1088c0050ef5b37c8f4eb3269ea4510160b Mon Sep 17 00:00:00 2001 From: arielerv Date: Fri, 10 Feb 2023 00:33:38 -0300 Subject: [PATCH 1/2] fix: first onchange of props and format value --- package.json | 2 +- src/components/DatePicker/DatePicker.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 265f4ff..9c9f024 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/DatePicker/DatePicker.js b/src/components/DatePicker/DatePicker.js index e8785d1..7fb1f6b 100644 --- a/src/components/DatePicker/DatePicker.js +++ b/src/components/DatePicker/DatePicker.js @@ -27,8 +27,8 @@ const DatePicker = ({ yearRange, ...props }) => { - const handleChange = newValue => form?.setFieldValue(field.name, newValue) - || onChange({target: {id: name, value: newValue}}); + const handleChange = newValue => (onChange ? onChange({target: {id: name, value: newValue.toISOString()}}) + : form?.setFieldValue(field.name, newValue.toISOString())); const customHeader = isCustomHeader ? { renderCustomHeader: datePickerProps => ( @@ -110,7 +110,7 @@ DatePicker.defaultProps = { variant: undefined, isDisabled: false, isCustomHeader: false, - onChange: () => {}, + onChange: undefined, form: undefined, field: undefined, selectsStart: false, From 726b46d103357ad7dc97024791e2fb7f7624c793 Mon Sep 17 00:00:00 2001 From: Maximiliano Raul Forlenza Date: Fri, 10 Feb 2023 11:57:11 -0300 Subject: [PATCH 2/2] refactor(datePicker): move value to constant --- src/components/DatePicker/DatePicker.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/DatePicker/DatePicker.js b/src/components/DatePicker/DatePicker.js index 7fb1f6b..41127ea 100644 --- a/src/components/DatePicker/DatePicker.js +++ b/src/components/DatePicker/DatePicker.js @@ -27,8 +27,12 @@ const DatePicker = ({ yearRange, ...props }) => { - const handleChange = newValue => (onChange ? onChange({target: {id: name, value: newValue.toISOString()}}) - : form?.setFieldValue(field.name, newValue.toISOString())); + 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 => (