React-dates: onNextMonthClick & onPrevMonthclick not passed down to DayPickerSingleDateController

Created on 20 Jul 2017  Â·  2Comments  Â·  Source: airbnb/react-dates

Hey,

First, thanks for an awesome component :) I've been using it for a few days and it's been much easier to use than other react datepickers I've tried.

My issue is that I'm trying to use a SingleDatePicker with restricted dates, which works great. However the user can still use the next / prev month navigation to go to months where there are no days available for them to select.

I thought I'd be able to stop this by playing around with the onNextMonthClick and onPrevMonthClick functions, however these don't seem to be passed down to the DayPickerSingleDateController, so only the empty function from defaultProps is called. Playing around with the src I was able to pass them from SingleDatePicker to the controller and they were called as expected.

I noticed that DateRangePicker doesn't have this issue. These functions are listed as optional props in the docs so I'm not sure if this is intentional and just something that shouldn't be used with the SingleDatePicker or if it's a bug?

Any help is appreciated, thanks again.

Most helpful comment

Hiyo! I think this has a couple of duplicate issues: https://github.com/airbnb/react-dates/issues/628 and https://github.com/airbnb/react-dates/issues/400. :)

I will close those in favor of this issue so we can have some discussion here.

I think with the expectation of how isOutsideRange works ((- ∞, X] or [Y, ∞) or both), it would be reasonable to have a disableOutsideRangeNavigation boolean prop that would allow for this behavior.

FYI @kakadiadarpan @AntiFish03

All 2 comments

I've been able to work around this for some use cases by using DayPickerSingleDateController, however it looks like onNextMonthClick doesn't let me stop the navigation.

It'd be great of there was a way to stop navigation when requesting a month that is outside the supplied range, but it's not a huge issue / blocker at the moment.

Hiyo! I think this has a couple of duplicate issues: https://github.com/airbnb/react-dates/issues/628 and https://github.com/airbnb/react-dates/issues/400. :)

I will close those in favor of this issue so we can have some discussion here.

I think with the expectation of how isOutsideRange works ((- ∞, X] or [Y, ∞) or both), it would be reasonable to have a disableOutsideRangeNavigation boolean prop that would allow for this behavior.

FYI @kakadiadarpan @AntiFish03

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jesus-Gonzalez picture Jesus-Gonzalez  Â·  3Comments

cemremengu picture cemremengu  Â·  3Comments

sag1v picture sag1v  Â·  3Comments

krissalvador27 picture krissalvador27  Â·  3Comments

maciej-w picture maciej-w  Â·  3Comments