Skip to content

Commit

Permalink
Fixes date fields autofilling on edit
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-sheldon committed Mar 23, 2024
1 parent 48098b8 commit 575ee8b
Showing 1 changed file with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,37 @@ interface DateFieldProps {
export function DateField(props: DateFieldProps): JSX.Element {
const classes = useStyles();

if (props.value) {
return (
<div className={classes.fieldRow}>
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DesktopDatePicker
className={classes.field}
data-testid={props.name}
label={props.label}
inputFormat="yyyy/MM/dd"
mask="____/__/__"
minDate={new Date('2019/12/01')}
disableFuture
value={props.value || undefined}
onChange={props.onChange}
renderInput={(params) => (
<MuiTextField
{...params}
name={props.name}
fullWidth
// Non formik component needs different error handling
error={!!props.errorMessage}
helperText={props.errorMessage}
/>
)}
/>
</LocalizationProvider>
{props.required && <RequiredHelperText name={props.name} />}
</div>
);
}

return (
<div className={classes.fieldRow}>
<LocalizationProvider dateAdapter={AdapterDateFns}>
Expand All @@ -204,7 +235,7 @@ export function DateField(props: DateFieldProps): JSX.Element {
mask="____/__/__"
minDate={new Date('2019/12/01')}
disableFuture
value={props.value}
value="yyyy/MM/dd"
onChange={props.onChange}
renderInput={(params) => (
<MuiTextField
Expand Down

0 comments on commit 575ee8b

Please sign in to comment.