react-datepicker: `openToDate` not working in `v0.41.1`

Currently the prop openToDate does not seem to work in v0.41.1. See, for example, https://hacker0x01.github.io/react-datepicker/#example-25

In my opinion, the bug is an unintended consequence of commit 418b8d33594b72f97f05c2ba37558305a969ad24 which introduced the preSelection prop in Calendar (https://github.com/Hacker0x01/react-datepicker/commit/418b8d33594b72f97f05c2ba37558305a969ad24#diff-53b2cf631ea5d028d238854eaa70ce16R107) that is filled with today if no date is selected hence if (initialDate) is always true.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 24 (19 by maintainers)

Commits related to this issue

Most upvoted comments

I found a quick fix (for now) just downgrading the version to v. 0.40.0

I want that selected date must be selected date )). And the openToDate must be the date on which calendar will open. No matter right or left or whatever. Selected may be today, but I want calendar to be opened at the openToDate date (may be 30 year before today or last age). OpenToDate it’s just like a scroll position.

@donysukardi That’s still not quite right. The default should not be outside the selectable range. (And it didn’t used to be in 0.39.)

It should at least take minDate and maxDate into account. (I don’t know whether it used to take excludeDates into account too as I didn’t use that prop.)

I’m working on a PR. I think we can remove the openToDate prop on the calendar due to the preSelection prop and move the validation, handling and test cases to the datepicker class.