[pickers][DateRangeCalendar] Using a controlled DateRangeCalendar
with currentMonthCalendarPosition
breaks scroll behaviour
#14418
Labels
bug 🐛
Something doesn't work
component: date range picker
This is the name of the generic UI component, not the React module!
component: pickers
This is the name of the generic UI component, not the React module!
Steps to reproduce
Link to live example: https://codesandbox.io/p/sandbox/muddy-cherry-x8jh2g
Steps:
DateRangeCalendar
with thecurrentMonthCalendarPosition
with a value other than1
value
to the component so that there's a "current" calendar. (ex a couple of days in August 2024)value
so that the next month becomes "current" (ex a couple of days in September 2024)Current behavior
The "current" calendar never changes, lingering on the previously active calendar (August in my example). Manually scrolling to the next month reveals the value is correctly interpreted, however not scrolled to. This is only true for sibling months (when
calendars={2}
)Expected behavior
The component should scroll to the "next" month so that my selection is always visible.
Context
In our application we have a preference to show the current month on the right, so we used
currentMonthCalendarPosition
to achieve this. We also have a number of shortcuts such as (last month, last week, this month etc) which users use to quickly make selections.I strongly suspect the reason the current behaviour is how it is, because
currentMonthCalendarPosition
isn't considered when scrolling. IfcurrentMonthCalendarPosition
was 1, the current behavior would make complete sense, since you'd only scroll if the "previous" month suddently became selected, not the "next" one.Your environment
npx @mui/envinfo
Search keywords: currentMonthCalendarPosition, calendar picker
The text was updated successfully, but these errors were encountered: