Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pickers] Set closeOnSelect prop default value to false on pickers containing time views #14397

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1107519
sets closeOnSelect to false by default on pickers containing time views
Aug 30, 2024
887eef1
update tests
Aug 30, 2024
a4c7ee5
update lifecycle docs
Aug 30, 2024
cf44c34
add description for mobile pickers
Sep 3, 2024
f77003f
add description for DatePicker and DateRangePicker
Sep 3, 2024
8adfacd
add prop description for DateTime and DateTimeRange pickers
Sep 3, 2024
9ad1a66
add prop description for time picker
Sep 3, 2024
243ba59
fix e2e tests
Sep 4, 2024
85994db
remove unnecessary code wrap
arthurbalduini Oct 9, 2024
93c9a64
add closeOnSelect default values mention on onClose section
arthurbalduini Oct 16, 2024
71430c2
fix grammar errors
arthurbalduini Oct 16, 2024
32fe2fc
update prop description on docs
arthurbalduini Oct 16, 2024
5765830
use 'accept' and 'cancel' actions by default on all components
arthurbalduini Oct 23, 2024
b4d0dd2
use valueType on layout
arthurbalduini Oct 23, 2024
89a4fea
style adjustments
arthurbalduini Oct 23, 2024
65df2e8
fix e2e test
arthurbalduini Oct 23, 2024
3d6ab99
Merge branch 'master' into refactor-time-picker-closing-behavior
arthurbalduini Oct 29, 2024
0b48a93
adapt DesktopTimePicker tests
arthurbalduini Oct 29, 2024
2ecd55a
use actions on DesktopDateTimeRangePicker
arthurbalduini Oct 29, 2024
24ac4f8
adds 'accept' action click on tests
arthurbalduini Oct 30, 2024
06b1cdd
removes unnecessary duplicated comment
arthurbalduini Oct 30, 2024
be35b9b
fix overextended interface
arthurbalduini Oct 30, 2024
34c1cce
define usePickerLayout as source of actions for actionBar
arthurbalduini Oct 30, 2024
ec4269c
remove FieldValueType in favor of ValueType
arthurbalduini Oct 30, 2024
0bb8cc1
remove unnecessary type ref
arthurbalduini Oct 30, 2024
9ab2c7d
proptypes and doc:api
arthurbalduini Oct 30, 2024
8af50b8
remove unnecessary imports
arthurbalduini Oct 31, 2024
26f9e34
revert layout changes
arthurbalduini Oct 31, 2024
37dcf54
revert ValueType usage
arthurbalduini Nov 5, 2024
2a2e1f9
Merge branch 'master' into refactor-time-picker-closing-behavior
arthurbalduini Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions docs/data/date-pickers/lifecycle/lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ In all the below scenarios, the picker closes when `onClose` is called, except i
#### When the last view is completed

When a selection in the last view is made, `onClose` will be called only if the `closeOnSelect` prop is equal to `true`.
By default, it is set to `true` on desktop and `false` on mobile.
The default value of `closeOnSelect` varies among the components:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The default value of `closeOnSelect` varies among the components:
The default value of `closeOnSelect` depends on the component used:

But I'll let @samuelsycamore check the wordings 🙏

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with your version @flaviendelangle 👍


Here are a few examples:
- `DatePicker` and `DateRangePicker`: `true` on desktop and `false` on mobile variants;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `DatePicker` and `DateRangePicker`: `true` on desktop and `false` on mobile variants;
- Date Picker and Date Range Picker: `true` on desktop and `false` on mobile variants.

- `TimePicker`, `DateTimePicker` and `DateTimeRangePicker`: `false` on both desktop and mobile variants.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `TimePicker`, `DateTimePicker` and `DateTimeRangePicker`: `false` on both desktop and mobile variants.
- Time Picker, Date Time Picker and Date Time Range Picker: `false` on both desktop and mobile variants.


Here are a few examples:

:::info
The examples below are using the desktop and mobile variants of the pickers, but the behavior is exactly the same when using the responsive variant (`DatePicker`, `TimePicker`, ...) on a mobile or desktop environment.
Expand Down Expand Up @@ -225,7 +228,10 @@ You can use the second argument passed to the `onAccept` callback to get the val
#### When the last view is completed

When a selection in the last view is made, `onAccept` will be called only if the `closeOnSelect` prop is equal to `true` and the value has been modified since the last time `onAccept` was called.
By default, `closeOnSelect`, is set to `true` on desktop and `false` on mobile.
The default value of `closeOnSelect` varies among the components:
arthurbalduini marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same changes as proposed above


- `DatePicker` and `DateRangePicker`: `true` on desktop and `false` on mobile variants;
- `TimePicker`, `DateTimePicker` and `DateTimeRangePicker`: `false` on both desktop and mobile variants.
Comment on lines +233 to +234
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as @flaviendelangle 's suggestion above: Date Picker, Date Range Picker, etc.


Here are a few examples:

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/x/api/date-pickers/date-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"autoFocus": { "type": { "name": "bool" } },
"closeOnSelect": {
"type": { "name": "bool" },
"default": "`true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop)."
"default": "`true` for desktop, `false` for mobile variant (based on the chosen wrapper and `desktopModeMediaQuery` prop)."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this supposed to be singular here but plural in the next one?

},
"dayOfWeekFormatter": {
"type": { "name": "func" },
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/x/api/date-pickers/date-range-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"closeOnSelect": {
"type": { "name": "bool" },
"default": "`true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop)."
"default": "`true` for desktop, `false` for mobile variants (based on the chosen wrapper and `desktopModeMediaQuery` prop)."
},
"currentMonthCalendarPosition": {
"type": { "name": "enum", "description": "1<br>&#124;&nbsp;2<br>&#124;&nbsp;3" },
Expand Down
5 changes: 1 addition & 4 deletions docs/pages/x/api/date-pickers/date-time-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"ampm": { "type": { "name": "bool" }, "default": "utils.is12HourCycleInCurrentLocale()" },
"ampmInClock": { "type": { "name": "bool" }, "default": "true on desktop, false on mobile" },
"autoFocus": { "type": { "name": "bool" } },
"closeOnSelect": {
"type": { "name": "bool" },
"default": "`true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop)."
},
"closeOnSelect": { "type": { "name": "bool" }, "default": "false" },
"dayOfWeekFormatter": {
"type": { "name": "func" },
"default": "(date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()",
Expand Down
5 changes: 1 addition & 4 deletions docs/pages/x/api/date-pickers/date-time-range-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"type": { "name": "enum", "description": "1<br>&#124;&nbsp;2<br>&#124;&nbsp;3" },
"default": "1"
},
"closeOnSelect": {
"type": { "name": "bool" },
"default": "`true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop)."
},
"closeOnSelect": { "type": { "name": "bool" }, "default": "false" },
"currentMonthCalendarPosition": {
"type": { "name": "enum", "description": "1<br>&#124;&nbsp;2<br>&#124;&nbsp;3" },
"default": "1"
Expand Down
5 changes: 1 addition & 4 deletions docs/pages/x/api/date-pickers/desktop-date-picker.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"props": {
"autoFocus": { "type": { "name": "bool" } },
"closeOnSelect": {
"type": { "name": "bool" },
"default": "`true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop)."
},
"closeOnSelect": { "type": { "name": "bool" }, "default": "true" },
"dayOfWeekFormatter": {
"type": { "name": "func" },
"default": "(date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()",
Expand Down
5 changes: 1 addition & 4 deletions docs/pages/x/api/date-pickers/desktop-date-range-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
"type": { "name": "enum", "description": "1<br>&#124;&nbsp;2<br>&#124;&nbsp;3" },
"default": "2"
},
"closeOnSelect": {
"type": { "name": "bool" },
"default": "`true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop)."
},
"closeOnSelect": { "type": { "name": "bool" }, "default": "true" },
"currentMonthCalendarPosition": {
"type": { "name": "enum", "description": "1<br>&#124;&nbsp;2<br>&#124;&nbsp;3" },
"default": "1"
Expand Down
5 changes: 1 addition & 4 deletions docs/pages/x/api/date-pickers/desktop-date-time-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"ampm": { "type": { "name": "bool" }, "default": "utils.is12HourCycleInCurrentLocale()" },
"ampmInClock": { "type": { "name": "bool" }, "default": "true on desktop, false on mobile" },
"autoFocus": { "type": { "name": "bool" } },
"closeOnSelect": {
"type": { "name": "bool" },
"default": "`true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop)."
},
"closeOnSelect": { "type": { "name": "bool" }, "default": "false" },
"dayOfWeekFormatter": {
"type": { "name": "func" },
"default": "(date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"type": { "name": "enum", "description": "1<br>&#124;&nbsp;2<br>&#124;&nbsp;3" },
"default": "1"
},
"closeOnSelect": {
"type": { "name": "bool" },
"default": "`true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop)."
},
"closeOnSelect": { "type": { "name": "bool" }, "default": "false" },
"currentMonthCalendarPosition": {
"type": { "name": "enum", "description": "1<br>&#124;&nbsp;2<br>&#124;&nbsp;3" },
"default": "1"
Expand Down
5 changes: 1 addition & 4 deletions docs/pages/x/api/date-pickers/desktop-time-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"ampm": { "type": { "name": "bool" }, "default": "utils.is12HourCycleInCurrentLocale()" },
"ampmInClock": { "type": { "name": "bool" }, "default": "true on desktop, false on mobile" },
"autoFocus": { "type": { "name": "bool" } },
"closeOnSelect": {
"type": { "name": "bool" },
"default": "`true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop)."
},
"closeOnSelect": { "type": { "name": "bool" }, "default": "false" },
"defaultValue": { "type": { "name": "object" } },
"disabled": { "type": { "name": "bool" }, "default": "false" },
"disableFuture": { "type": { "name": "bool" }, "default": "false" },
Expand Down
5 changes: 1 addition & 4 deletions docs/pages/x/api/date-pickers/mobile-date-picker.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"props": {
"autoFocus": { "type": { "name": "bool" } },
"closeOnSelect": {
"type": { "name": "bool" },
"default": "`true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop)."
},
"closeOnSelect": { "type": { "name": "bool" }, "default": "false" },
"dayOfWeekFormatter": {
"type": { "name": "func" },
"default": "(date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()",
Expand Down
5 changes: 1 addition & 4 deletions docs/pages/x/api/date-pickers/mobile-date-range-picker.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"props": {
"autoFocus": { "type": { "name": "bool" } },
"closeOnSelect": {
"type": { "name": "bool" },
"default": "`true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop)."
},
"closeOnSelect": { "type": { "name": "bool" }, "default": "false" },
"currentMonthCalendarPosition": {
"type": { "name": "enum", "description": "1<br>&#124;&nbsp;2<br>&#124;&nbsp;3" },
"default": "1"
Expand Down
5 changes: 1 addition & 4 deletions docs/pages/x/api/date-pickers/mobile-date-time-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"ampm": { "type": { "name": "bool" }, "default": "utils.is12HourCycleInCurrentLocale()" },
"ampmInClock": { "type": { "name": "bool" }, "default": "true on desktop, false on mobile" },
"autoFocus": { "type": { "name": "bool" } },
"closeOnSelect": {
"type": { "name": "bool" },
"default": "`true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop)."
},
"closeOnSelect": { "type": { "name": "bool" }, "default": "false" },
"dayOfWeekFormatter": {
"type": { "name": "func" },
"default": "(date: TDate) => adapter.format(date, 'weekdayShort').charAt(0).toUpperCase()",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
"props": {
"ampm": { "type": { "name": "bool" }, "default": "utils.is12HourCycleInCurrentLocale()" },
"autoFocus": { "type": { "name": "bool" } },
"closeOnSelect": {
"type": { "name": "bool" },
"default": "`true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop)."
},
"closeOnSelect": { "type": { "name": "bool" }, "default": "false" },
"currentMonthCalendarPosition": {
"type": { "name": "enum", "description": "1<br>&#124;&nbsp;2<br>&#124;&nbsp;3" },
"default": "1"
Expand Down
5 changes: 1 addition & 4 deletions docs/pages/x/api/date-pickers/mobile-time-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"ampm": { "type": { "name": "bool" }, "default": "utils.is12HourCycleInCurrentLocale()" },
"ampmInClock": { "type": { "name": "bool" }, "default": "true on desktop, false on mobile" },
"autoFocus": { "type": { "name": "bool" } },
"closeOnSelect": {
"type": { "name": "bool" },
"default": "`true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop)."
},
"closeOnSelect": { "type": { "name": "bool" }, "default": "false" },
"defaultValue": { "type": { "name": "object" } },
"disabled": { "type": { "name": "bool" }, "default": "false" },
"disableFuture": { "type": { "name": "bool" }, "default": "false" },
Expand Down
5 changes: 1 addition & 4 deletions docs/pages/x/api/date-pickers/time-picker.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"ampm": { "type": { "name": "bool" }, "default": "utils.is12HourCycleInCurrentLocale()" },
"ampmInClock": { "type": { "name": "bool" }, "default": "true on desktop, false on mobile" },
"autoFocus": { "type": { "name": "bool" } },
"closeOnSelect": {
"type": { "name": "bool" },
"default": "`true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop)."
},
"closeOnSelect": { "type": { "name": "bool" }, "default": "false" },
"defaultValue": { "type": { "name": "object" } },
"desktopModeMediaQuery": {
"type": { "name": "string" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ DateRangePicker.propTypes = {
className: PropTypes.string,
/**
* If `true`, the popover or modal will close after submitting the full date.
* @default `true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop).
* @default `true` for desktop, `false` for mobile variants (based on the chosen wrapper and `desktopModeMediaQuery` prop).
*/
closeOnSelect: PropTypes.bool,
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export interface DateRangePickerProps<
* @default {}
*/
slotProps?: DateRangePickerSlotProps<TDate, TEnableAccessibleFieldDOMStructure>;
/**
* If `true`, the popover or modal will close after submitting the full date.
* @default `true` for desktop, `false` for mobile variants (based on the chosen wrapper and `desktopModeMediaQuery` prop).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @default `true` for desktop, `false` for mobile variants (based on the chosen wrapper and `desktopModeMediaQuery` prop).
* @default `true` for desktop, `false` for mobile variant (based on the chosen wrapper and `desktopModeMediaQuery` prop).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are not deciding between variant usage.
WDYT about dropping this addition and keeping the description as is? 🤔

Suggested change
* @default `true` for desktop, `false` for mobile variants (based on the chosen wrapper and `desktopModeMediaQuery` prop).
* @default `true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it reads more clearly without "variant" so unless it's absolutely necessary for clarity then I'd leave it out.

*/
closeOnSelect?: boolean;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ DateTimeRangePicker.propTypes = {
className: PropTypes.string,
/**
* If `true`, the popover or modal will close after submitting the full date.
* @default `true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop).
* @default false
*/
closeOnSelect: PropTypes.bool,
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ export interface BaseDateTimeRangePickerProps<TDate extends PickerValidDate>
* If `undefined`, internally defined view will be used.
*/
viewRenderers?: Partial<DateTimeRangePickerRenderers<TDate, DateTimeRangePickerView>>;
/**
* If `true`, the popover or modal will close after submitting the full date.
* @default false
*/
closeOnSelect?: boolean;
Comment on lines +119 to +123
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could update the JSDoc of this prop on UsePickerValueNonStaticProps type definition since it is now the most common default.
Then we can keep the overrides only for DateRangePicker and DesktopDateRangePicker. 🤔
WDYT?

Suggested change
/**
* If `true`, the popover or modal will close after submitting the full date.
* @default false
*/
closeOnSelect?: boolean;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The less override we have the better 🙏

}

type UseDateTimeRangePickerDefaultizedProps<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ DesktopDateRangePicker.propTypes = {
className: PropTypes.string,
/**
* If `true`, the popover or modal will close after submitting the full date.
* @default `true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop).
* @default true
*/
closeOnSelect: PropTypes.bool,
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@ export interface DesktopDateRangePickerProps<
* @default {}
*/
slotProps?: DesktopDateRangePickerSlotProps<TDate, TEnableAccessibleFieldDOMStructure>;
/**
* If `true`, the popover or modal will close after submitting the full date.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have a specific definition per component, we know its default behavior.

Suggested change
* If `true`, the popover or modal will close after submitting the full date.
* If `true`, the popover will close after submitting the full date.

Otherwise, we could go the more abstract route to avoid the need to update the JSDoc when we move range pickers away from the tooltip to dialog/popover. 🤔

Suggested change
* If `true`, the popover or modal will close after submitting the full date.
* If `true`, the Picker will close after submitting the full date.

* @default true
*/
closeOnSelect?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
} from '@mui/x-date-pickers/internals';
import { extractValidationProps } from '@mui/x-date-pickers/validation';
import { PickerOwnerState, PickerValidDate } from '@mui/x-date-pickers/models';
import { PickersLayoutOwnerState } from '@mui/x-date-pickers/PickersLayout';
import resolveComponentProps from '@mui/utils/resolveComponentProps';
import { refType } from '@mui/utils';
import {
Expand All @@ -25,7 +24,6 @@ import {
} from '@mui/x-date-pickers/MultiSectionDigitalClock';
import Divider from '@mui/material/Divider';
import { digitalClockClasses } from '@mui/x-date-pickers/DigitalClock';
import type { PickersActionBarAction } from '@mui/x-date-pickers/PickersActionBar';
import { DesktopDateTimePickerLayout } from '@mui/x-date-pickers/DesktopDateTimePicker';
import { rangeValueManager } from '../internals/utils/valueManagers';
import { DesktopDateTimeRangePickerProps } from './DesktopDateTimeRangePicker.types';
Expand Down Expand Up @@ -168,8 +166,6 @@ const DesktopDateTimeRangePicker = React.forwardRef(function DesktopDateTimeRang
const views = !shouldHoursRendererContainMeridiemView
? defaultizedProps.views.filter((view) => view !== 'meridiem')
: defaultizedProps.views;
const actionBarActions: PickersActionBarAction[] =
defaultizedProps.shouldRenderTimeInASingleColumn ? [] : ['accept'];

const props = {
...defaultizedProps,
Expand Down Expand Up @@ -200,10 +196,6 @@ const DesktopDateTimeRangePicker = React.forwardRef(function DesktopDateTimeRang
toolbarVariant: 'desktop',
...defaultizedProps.slotProps?.toolbar,
},
actionBar: (ownerState: PickersLayoutOwnerState) => ({
actions: actionBarActions,
...resolveComponentProps(defaultizedProps.slotProps?.actionBar, ownerState),
}),
},
};

Expand Down Expand Up @@ -248,7 +240,7 @@ DesktopDateTimeRangePicker.propTypes = {
className: PropTypes.string,
/**
* If `true`, the popover or modal will close after submitting the full date.
* @default `true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop).
* @default false
*/
closeOnSelect: PropTypes.bool,
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ MobileDateRangePicker.propTypes = {
className: PropTypes.string,
/**
* If `true`, the popover or modal will close after submitting the full date.
* @default `true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop).
* @default false
*/
closeOnSelect: PropTypes.bool,
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MakeOptional } from '@mui/x-date-pickers/internals';
import { MakeOptional, MobileOnlyPickerProps } from '@mui/x-date-pickers/internals';
import { PickerValidDate } from '@mui/x-date-pickers/models';
import {
UseMobileRangePickerSlots,
Expand Down Expand Up @@ -28,6 +28,7 @@ export interface MobileDateRangePickerProps<
TDate extends PickerValidDate,
TEnableAccessibleFieldDOMStructure extends boolean = true,
> extends BaseDateRangePickerProps<TDate>,
Pick<MobileOnlyPickerProps, 'closeOnSelect'>,
MobileRangeOnlyPickerProps {
/**
* Overridable component slots.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ MobileDateTimeRangePicker.propTypes = {
className: PropTypes.string,
/**
* If `true`, the popover or modal will close after submitting the full date.
* @default `true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop).
* @default false
*/
closeOnSelect: PropTypes.bool,
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MakeOptional } from '@mui/x-date-pickers/internals';
import { MakeOptional, MobileOnlyPickerProps } from '@mui/x-date-pickers/internals';
import { PickerValidDate } from '@mui/x-date-pickers/models';
import {
UseMobileRangePickerSlots,
Expand Down Expand Up @@ -33,6 +33,7 @@ export interface MobileDateTimeRangePickerProps<
TDate extends PickerValidDate,
TEnableAccessibleFieldDOMStructure extends boolean = true,
> extends BaseDateTimeRangePickerProps<TDate>,
Pick<MobileOnlyPickerProps, 'closeOnSelect'>,
MobileRangeOnlyPickerProps {
/**
* Overridable component slots.
Expand Down
2 changes: 1 addition & 1 deletion packages/x-date-pickers/src/DatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ DatePicker.propTypes = {
className: PropTypes.string,
/**
* If `true`, the popover or modal will close after submitting the full date.
* @default `true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop).
* @default `true` for desktop, `false` for mobile variant (based on the chosen wrapper and `desktopModeMediaQuery` prop).
*/
closeOnSelect: PropTypes.bool,
/**
Expand Down
5 changes: 5 additions & 0 deletions packages/x-date-pickers/src/DatePicker/DatePicker.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ export interface DatePickerProps<
* @default 4 on desktop, 3 on mobile
*/
yearsPerRow?: 3 | 4;
/**
* If `true`, the popover or modal will close after submitting the full date.
* @default `true` for desktop, `false` for mobile variant (based on the chosen wrapper and `desktopModeMediaQuery` prop).
Copy link
Member

@flaviendelangle flaviendelangle Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not fan of just adding variant after mobile here, I would stick with the old wording or use variants for both:

Suggested change
* @default `true` for desktop, `false` for mobile variant (based on the chosen wrapper and `desktopModeMediaQuery` prop).
* @default `true` for the desktop variant, `false` for the mobile variant (based on the chosen wrapper and `desktopModeMediaQuery` prop).

or

Suggested change
* @default `true` for desktop, `false` for mobile variant (based on the chosen wrapper and `desktopModeMediaQuery` prop).
* @default `true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We currently call them "variants" in the doc as well. 🙈
P.S. Both of your suggestions seem to be the same. 🙈

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion updated 😆
My problem is not using the word "variant", it's the phrasing "true for desktoop, false for mobile variant" which seems inconsistent to me.

*/
closeOnSelect?: boolean;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ DateTimePicker.propTypes = {
className: PropTypes.string,
/**
* If `true`, the popover or modal will close after submitting the full date.
* @default `true` for desktop, `false` for mobile (based on the chosen wrapper and `desktopModeMediaQuery` prop).
* @default false
*/
closeOnSelect: PropTypes.bool,
/**
Expand Down
5 changes: 5 additions & 0 deletions packages/x-date-pickers/src/DateTimePicker/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ export interface BaseDateTimePickerProps<
* If `undefined`, internally defined view will be used.
*/
viewRenderers?: Partial<DateTimePickerViewRenderers<TDate, TView>>;
/**
* If `true`, the popover or modal will close after submitting the full date.
* @default false
*/
closeOnSelect?: boolean;
}

type UseDateTimePickerDefaultizedProps<
Expand Down
Loading