Skip to content

Commit

Permalink
Improve demo
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviendelangle committed Oct 7, 2024
1 parent 9443b65 commit 018158d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
useParsedFormat,
usePickersContext,
} from '@mui/x-date-pickers/hooks';
import { CalendarIcon } from '@mui/x-date-pickers/icons';

function ReadOnlyDateField(props) {
const { internalProps, forwardedProps } = useSplitFieldProps(props, 'date');
Expand All @@ -34,12 +35,19 @@ function ReadOnlyDateField(props) {
}
};

console.log(InputProps);

return (
<TextField
{...other}
value={value == null ? '' : value.format(format)}
placeholder={parsedFormat}
InputProps={{ ...InputProps, readOnly: true }}
InputProps={{
...InputProps,
readOnly: true,
endAdornment: <CalendarIcon color="action" />,
sx: { cursor: 'pointer', '& *': { cursor: 'inherit' } },
}}
error={hasValidationError}
onClick={handleTogglePicker}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
useParsedFormat,
usePickersContext,
} from '@mui/x-date-pickers/hooks';
import { CalendarIcon } from '@mui/x-date-pickers/icons';

function ReadOnlyDateField(props: DatePickerFieldProps<Dayjs, false>) {
const { internalProps, forwardedProps } = useSplitFieldProps(props, 'date');
Expand Down Expand Up @@ -43,7 +44,12 @@ function ReadOnlyDateField(props: DatePickerFieldProps<Dayjs, false>) {
{...other}
value={value == null ? '' : value.format(format)}
placeholder={parsedFormat}
InputProps={{ ...InputProps, readOnly: true }}
InputProps={{
...InputProps,
readOnly: true,
endAdornment: <CalendarIcon color="action" />,
sx: { cursor: 'pointer', '& *': { cursor: 'inherit' } },
}}
error={hasValidationError}
onClick={handleTogglePicker}
/>
Expand Down

0 comments on commit 018158d

Please sign in to comment.