Skip to content

selectsMultiple and selectsRange - default dates or manual typing in dates does not navigate to those months #5597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
michaelsawyers opened this issue Apr 22, 2025 · 0 comments

Comments

@michaelsawyers
Copy link

michaelsawyers commented Apr 22, 2025

Describe the bug
When I use selectsMultiple or selectsRange with a default selectedDates for selectsMultiple or manually typing in dates with selectsRange, the popover does not navigate to the months of the selected dates.

Note: this seems to just be a navigation issue, if I use nav arrows to the months of my selected months I do see the dates are properly selected.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Date range for one datepicker example on demo site, and type in a date range for a different month than you see in the popover
  2. Notice the popover is not navigated to the month of the selected dates

AND

  1. Go to Select multiple dates example on demo site, and switch the useState default date to a different date that is outside the current month shown in the popover
  2. Notice the popover is not navigated to the month of the default date (also testing in local code with initial render also not showing the popover as the default date's month)

Expected behavior
When I set default dates in selectsMultiple, or type in a date range manually in input for selectsRange, I expect to see the popover be navigated to the month of dates selected.

Screenshots
Image

Screen.Recording.2025-04-22.at.4.54.44.PM.mov

Desktop (please complete the following information):

  • OS: Mac
  • Browser: Chrome
  • Version: modern versions

My workaround is to deal with this in custom onChange, if selectsMultiple or selectsRange, use datepicker ref to set preSelection via setPreSelection to the first/start date once its passing as isValid. Would love to know if there are consequences to this, or if there is a better route. I preferred not setting ref.current.setSelected as I think this is more drastic than just setting the preSelected which just navigates.

ie. For date range case:

if (isValid(startDate)) {
   datePickerRef?.current?.setPreSelection(startDate);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant