Bug: DayPicker does not automatically navigate to selected date
tyforcode opened this issue · comments
Bug description
Thanks for the library! I found an issue where if you set the selected
value of the <DayPicker>
component with something like an initial state, the component will not show the selected date in the UI. Instead, it will default to the earliest date in the range.
To reproduce
https://codesandbox.io/p/sandbox/react-daypicker-forked-4n69dz
Steps
- Step an initial
Date
state - Set the following props on the
DayPicker
component
fromDate={new Date("10/10/2020")}
toDate={new Date("02/02/2022")}
captionLayout="dropdown"
- Observe the component or refresh the sample to demonstrate the bug
Expected behavior
Ideally, the DayPicker
component would show the selected
value by default when it's set by an outside state.
Screenshots
n/a
Additional context
My specific use case is around a combination of fromDate
, toDate
and captionLayout
where the year does not change correctly. However, this is also applicable to the base DayPicker
component.