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

Add isValid callback prop to allow locking dates #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rstrand
Copy link

@rstrand rstrand commented Jun 7, 2016

I have added an isValid callback which enables you to lock certain dates. This should be part of what issue #2 is asking.

I have had to change the standard behaviour slightly so that changing the month in the calendar view doesn't automatically update the date selected by the component until you actually click on a new date. This is to avoid a locked date becoming selected when the month is changed and allow you to navigate through an entirely locked month.

The isValid callback should look something like this:

function isValid(m) {
  // Disable weekends
  return m.day() != 0 && m.day() != 6;
}

aikar added a commit to aikar/input-moment that referenced this pull request Feb 24, 2017
Had to reimplement, but appears to work
@aikar
Copy link

aikar commented Feb 24, 2017

@rstrand note there is a behavior change in this implementation, in that currently the moment object that's been passed in gets mutated vs cloned.

Now, i dont know if the author intends/desires the mutation aspect.

however, I updated this logic into the latest input-moment, and can be found here:
aikar@0523d81

And also preserves the mutation logic by only cloning on test cases and doesnt use the state for month as you were doing.

@wangzuo this is a pretty critical functionality need for any user of this component, so i hope you can get my version in (As i said in the other issue, i'm under super time crunch mode so i dont have the time to split my changes into separate PR's)

@rstrand
Copy link
Author

rstrand commented Dec 12, 2018

I've rebased this pull request on the current master

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

Successfully merging this pull request may close these issues.

None yet

2 participants