From 05bb7799ea7a05137315759ff6fdc36c24fb342b Mon Sep 17 00:00:00 2001 From: bryancunningham-okta Date: Tue, 30 Jul 2024 12:51:28 -0400 Subject: [PATCH] refactor(odyssey-react-mui): show error if full date has been entered --- packages/odyssey-react-mui/src/labs/DateField.tsx | 5 +++++ packages/odyssey-react-mui/src/labs/DatePicker.tsx | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/odyssey-react-mui/src/labs/DateField.tsx b/packages/odyssey-react-mui/src/labs/DateField.tsx index 07dcb66de6..9e1966b78b 100644 --- a/packages/odyssey-react-mui/src/labs/DateField.tsx +++ b/packages/odyssey-react-mui/src/labs/DateField.tsx @@ -147,12 +147,17 @@ const DateField = ({ (value, validationContext) => { clearErrorMessages(); const { validationError } = validationContext; + const hasEnteredFullYear = value?.year.toString().length === 4; if (validationError) { const odysseyValidationError = errorMap.get(validationError); if (odysseyValidationError) { internalValidationError.current = odysseyValidationError; + + if (value?.isValid && hasEnteredFullYear) { + setDisplayedErrorMessage(odysseyValidationError); + } } } diff --git a/packages/odyssey-react-mui/src/labs/DatePicker.tsx b/packages/odyssey-react-mui/src/labs/DatePicker.tsx index 213a3600eb..157b6ae42b 100644 --- a/packages/odyssey-react-mui/src/labs/DatePicker.tsx +++ b/packages/odyssey-react-mui/src/labs/DatePicker.tsx @@ -27,7 +27,6 @@ import { LocalizationProvider, PickersActionBarProps, DatePickerSlotProps, - // DateTimeValidationError, } from "@mui/x-date-pickers"; import { DateTime } from "luxon"; import { AdapterLuxon } from "@mui/x-date-pickers/AdapterLuxon";