react-day-picker
react-day-picker copied to clipboard
toDate and fromDate are not working as expected
Description
I'm encountering an issue with the toDate and the fromDate props of react-day-picker where it seems to behave more like toMonth and fromMonth. When setting a specific date as a limit using toDate, I expect the calendar to restrict the selection of days only up until that specific date. However, what happens is that the calendar allows any day within the month of the provided limit date to be selected, not just up to the exact date. Same case for fromDate.
Expected Behavior
I expect that when using the toDate prop to set a date limit on the calendar, only days up to that specific date (inclusive) should be selectable. For example, if toDate is set to 2024-03-16T23:00:00.000Z, no day after March 16th, 2024, should be selectable.
Actual Behavior
When I set a limit using toDate, the calendar allows days beyond the provided limit date to be selected, up until the end of the month of the limit date. For example, if toDate is set to 2024-03-16, days after March 16th, 2024, are selectable, up until the end of March.
Steps to Reproduce
- Add the toDate prop to the DayPicker component with a specific value (e.g., new Date(2024, 2, 16)).
- Try selecting a day on the calendar after the provided date.
Possible Solution
A possible solution might involve reviewing how selectable dates are calculated in the context of the toDate prop to ensure that the exact day's time of the specified date is being respected, rather than allowing additional days within the same month to be selected.
Your Environment
- React version: 18.2.0
- Browser: Chrome 121.0.6167.184
- Operating System: macOS 14.2.1