diff --git a/packages/material/src/controls/MaterialDateControl.tsx b/packages/material/src/controls/MaterialDateControl.tsx index 0daf295b2..baea6cfe7 100644 --- a/packages/material/src/controls/MaterialDateControl.tsx +++ b/packages/material/src/controls/MaterialDateControl.tsx @@ -32,13 +32,18 @@ import { rankWith, } from '@jsonforms/core'; import { withJsonFormsControlProps } from '@jsonforms/react'; -import { FormHelperText, Hidden, TextField } from '@mui/material'; +import { FormHelperText, Hidden } from '@mui/material'; import { DatePicker, LocalizationProvider } from '@mui/lab'; import AdapterDayjs from '@mui/lab/AdapterDayjs'; -import { createOnChangeHandler, getData, useFocus } from '../util'; +import { + createOnChangeHandler, + getData, + ResettableTextField, + useFocus, +} from '../util'; export const MaterialDateControl = (props: ControlProps)=> { const [focused, onFocus, onBlur] = useFocus(); @@ -80,12 +85,15 @@ export const MaterialDateControl = (props: ControlProps)=> { saveFormat ),[path, handleChange, saveFormat]); + const value = getData(data, saveFormat); + const valueInInputFormat = value ? value.format(format) : ''; + return ( { clearText={appliedUiSchemaOptions.clearLabel} okText={appliedUiSchemaOptions.okLabel} renderInput={params => ( -