Skip to content

Commit 49b1e2c

Browse files
[DateRangePicker] Allow to override the format in the field
1 parent 48666ad commit 49b1e2c

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

packages/x-date-pickers-pro/src/DesktopDateRangePicker/DesktopDateRangePicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const DesktopDateRangePicker = React.forwardRef(function DesktopDateRangePicker<
5555
...defaultizedProps,
5656
closeOnSelect: defaultizedProps.closeOnSelect ?? true,
5757
viewRenderers,
58-
format: utils.formats.keyboardDate,
58+
format: defaultizedProps.format ?? utils.formats.keyboardDate, // TODO: Replace with resolveDateFormat() once we support month and year views
5959
calendars: defaultizedProps.calendars ?? 2,
6060
views: ['day'] as const,
6161
openTo: 'day' as const,

packages/x-date-pickers-pro/src/MobileDateRangePicker/MobileDateRangePicker.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ const MobileDateRangePicker = React.forwardRef(function MobileDateRangePicker<
5454
const props = {
5555
...defaultizedProps,
5656
viewRenderers,
57-
format: utils.formats.keyboardDate,
57+
format: defaultizedProps.format ?? utils.formats.keyboardDate, // TODO: Replace with resolveDateFormat() once we support month and year views
58+
5859
// Force one calendar on mobile to avoid layout issues
5960
calendars: 1,
6061
// force current calendar position, since we only have one calendar

packages/x-date-pickers/src/internals/hooks/usePicker/usePicker.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ export const usePicker = <
273273
],
274274
);
275275

276+
console.log(format);
277+
276278
const contextValue = React.useMemo<PickerContextValue<TValue, TView, TError>>(
277279
() => ({
278280
...actionsContextValue,

0 commit comments

Comments
 (0)