From 2be8e7c2ea3470149ca2a5605125ae71f6257d07 Mon Sep 17 00:00:00 2001 From: Dorin-RFL Date: Tue, 24 Dec 2024 14:51:23 +0200 Subject: [PATCH] fix: datePicker setFieldTouched true on change (#572) Co-authored-by: Alex Lebinson --- .../field-value-presentors/date.value-presentor.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/discrete-layer/components/layer-details/field-value-presentors/date.value-presentor.tsx b/src/discrete-layer/components/layer-details/field-value-presentors/date.value-presentor.tsx index 9c6014db..144b06d8 100644 --- a/src/discrete-layer/components/layer-details/field-value-presentors/date.value-presentor.tsx +++ b/src/discrete-layer/components/layer-details/field-value-presentors/date.value-presentor.tsx @@ -78,6 +78,13 @@ export const DateValuePresentorComponent: React.FC = ({ onChange={ (dateVal, val): void => { const momentVal = moment(dateVal, getDateformatType(shouldShowTime)); + const maxNowValidation = (fieldInfo.validation?.find((valid)=> valid.max === '$NOW'))? new Date(): null; + formik?.setFieldTouched(fieldName, true); + if(maxNowValidation){ + if (dateVal > maxNowValidation){ + formik?.setFieldError(fieldName, ''); + }; + } handleOnChange({ /* eslint-disable */ persist: () => {},