Skip to content
New issue

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

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

Already on GitHub? # to your account

Calendar should open on month containing minDate when date picker has no value. #209

Closed
kjarbr opened this issue Dec 2, 2019 · 7 comments
Assignees
Labels
bug Something isn't working stale

Comments

@kjarbr
Copy link

kjarbr commented Dec 2, 2019

Calendar default opens on month containing current date. It should instead show month containing min date.

@alicerocheman
Copy link

minDate, maxDate... anything but a date outside of the boundaries would be good!

@wojtekmaj
Copy link
Owner

You're correct - by calendar should default to selected date or today's date, limited by minDate and maxDate.

For now, you can use activeStartDate to override default displayed month.

@wojtekmaj wojtekmaj self-assigned this Dec 29, 2019
@wojtekmaj wojtekmaj added the bug Something isn't working label Dec 29, 2019
@arpitprod
Copy link

After added activeStartDate, I can't change calendar's month or year

date-picker.mov

@WillJiCar
Copy link

This issue is still happening, adding activeStartDate breaks the back and next buttons on the calendar.

I had to put in a hacky workaround. I'm using Formik with the date field being null initially (and so the calendar is blank on load) - when the component loads it creates a useState which stores this initial value (either null, or a date).

const [date, setDate] = useState(field.value) //Will grab whatevers in initialValues (date or null). This is how we'll control the temporary date state if the initialValue is null.

onChange={(e) => { field.setFieldValue("Date", e) } //This will only trigger if a date is physically entered by a user, so will not be triggered by changing the date state

onCalendarOpen={() => { if(date == null){ setDate(maxDate) } //Temporarily set the date to the max date so the calendar jumps to it if the initialValue is null.

onCalendarClose={() => { if( formikDateIsNull ){ setDate(null) } //Luckily setting the value using state does not trigger the onChange method, allowing for us to check if the user changed the date from the temporary value

value={date} //Either formik value (null or date) or our temporary value (maxDate)

@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2022

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.

@github-actions github-actions bot added the stale label Jan 3, 2022
@github-actions
Copy link
Contributor

This issue was closed because it has been stalled for 14 days with no activity.

@mariusrak
Copy link

Hi, I also encountered this. Could this be fixed? I tried the activeStartDate workaround, but that didn't work.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

6 participants