Skip to content

[pickers] Allow controlling the currently displayed year and month in the calendar components #16108

@KilianB

Description

@KilianB

Summary

Currently the referenceDate can be used to define which month of the DateCalendar is initially displayed, but changes to it do not reflect in the current month displayed in the date calendar. I am trying to replace the next and previous Buttons with my own implementation.

 <DateCalendar
    minDate={dayjs()}
    views={["day"]}
    referenceDate={referenceDateRight}
    slots={{
      nextIconButton: () => <></>,
      previousIconButton: () => <></>,
    }}
  />

I explicitly do not want to set the value or the default value of the component, but just control which month and date is displayed to the user

Examples

image

Motivation

As shown in the example the goal is to have multiple date pickers next to each other. In order to synch those I need to control the displayed month.
This can somehow we achieved by making the key dependent on the reference value, but this means that we are remounting the entire component every time we are changing the month.

The same motivation could previously be found here: https://stackoverflow.com/questions/76998078/how-can-i-have-two-calendars-in-the-datepicker-component-of-mui

Search keywords: reference date controlled date calendar

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists.scope: pickersChanges related to the date/time pickers.type: new featureExpand the scope of the product to solve a new problem.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions