Skip to content

Commit

Permalink
refactor(odyssey-react-mui): show error if full date has been entered
Browse files Browse the repository at this point in the history
  • Loading branch information
bryancunningham-okta committed Jul 30, 2024
1 parent 631367f commit 05bb779
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/odyssey-react-mui/src/labs/DateField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down
1 change: 0 additions & 1 deletion packages/odyssey-react-mui/src/labs/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 05bb779

Please sign in to comment.