Skip to content
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

Disable current and previous days on DayPicker component? #81

Closed
JimmyMultani opened this issue Sep 13, 2016 · 4 comments
Closed

Disable current and previous days on DayPicker component? #81

JimmyMultani opened this issue Sep 13, 2016 · 4 comments

Comments

@JimmyMultani
Copy link

Hello,

Is there a way to disable current/previous days on the component?

This is the way I'm currently calling it:

<DayPicker onDayClick={this.onDateChange} enableOutsideDays={false} numberOfMonths={1} />;

Any help would be greatly appreciated.

Thanks!

@majapw
Copy link
Collaborator

majapw commented Sep 13, 2016

enableOutsideDays refers to days in the table belonging to the previous and next month (ie August 31st or October 1st for this month). It is set to false by default so you don't necessary need that. By default past days are disabled using the isOutsideRange prop. You can also use isDayBlocked for more granularity. Does this answer your Q?

isOutsideRange indicates which days are out of selectable range. Past dates out of range by default. If you would like to allow the user to select days in the past, you may set isOutsideRange to () => false.

Right now we have an expectation that this function returns true for a continuous range of dates from -Infinity to some date and/or from some date to +Infinity. This is relevant to the minimum nights logic. If you would like to prevent the user from selecting a non-continuous set of dates, you should use isDayBlocked instead.

@JimmyMultani
Copy link
Author

Hey @majapw,

isOutsideRange doesn't seem to work for <DayPicker />. I am still able to click on past days, when I shouldn't be.

I think I might be using this incorrectly, but I'm not really sure.

Any assistance would be greatly appreciated.

Thank you.

@majapw
Copy link
Collaborator

majapw commented Sep 16, 2016

Oh man, I was totally incorrect in my response. I thought you were trying to use the SingleDatePicker component. You are right, neither of the isOutsideRange or isDayBlocked props apply to the DayPicker. You have to use the modifiers prop to wrangle it to what you want to do. I've detailed some of this in #82 (comment). Let me know if this helps!

@JimmyMultani
Copy link
Author

Hey @majapw,

You're example code helped tremendously on explaining what I wasn't doing correctly.

Thank you so much!

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

2 participants