Pressing Escape or clicking outside the picker will close the Muix DateTimePicker

90 Views Asked by At

Following the example will close the DateTimePicker when clicking on the actions button; however, pressing Escape or clicking outside the picker will also close it. I need to close the DateTimePicker only when the user presses the action buttons.

I haven't come across any props to control this.

<DesktopDatePicker closeOnSelect={false} slotProps={{ actionBar: { actions: ['cancel', 'accept'] } }} />

1

There are 1 best solutions below

1
Bhavy Ladani On

There is a prop called 'closeWidgets' to use here.

Try doing it like this:

<DesktopDatePicker
  slotProps={{
    actionBar: {
      actions: ['cancel', 'accept'],
      onClose: (action) => closePickerOnAction(action) && closePicker(),
    },
  }}
  closeWidgets={false}
/>

Do let me know how it goes and works.