Repository navigation
Conversation
… min/max range The calendar shows a day as selectable when any part of it is inside [minDate, maxDate], but the click merges the day with the current time (or midnight) and drops the selection if that moment is out of range. With minDate set to now, today looks selectable but clicking it does nothing. Clamp the merged time to minDate/maxDate when it falls on the same day.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The calendar marks a day as selectable when any part of it is inside the range (
minDate <= day.endOf('day'),maxDate >= day.startOf('day')), butonDateSelectmerges the clicked day with the current selection's time (or midnight when nothing is selected) and silently drops the click if that exact moment is out of range.The most common way to hit this is
minDate={new Date()}with no value: today is shown as selectable, but clicking it builds today at 00:00, which is beforeminDate, so nothing happens. The same thing happens with a selected time earlier thanminDate's time on the first day, or later thanmaxDate's time on the last day.This change clamps the merged time to
minDate/maxDatewhen it falls on the same day as the bound, so a click on a day the calendar shows as selectable always selects it. Days entirely outside the range are still ignored, and times already inside the range are unchanged.Testing: added
__tests__/datepicker.spec.tsx(4 cases). The two clamping cases fail on main (the click is ignored andonChangegets the old value) and pass with the fix; the in-range and fully-out-of-range cases pass on both.yarn test(72 passed),yarn linton the touched files,yarn typecheckandprettier --checkpass locally.I used AI assistance while working on this and reviewed and tested the change myself.