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 dates in the future #2

Open
siboscol opened this issue Sep 13, 2019 · 7 comments
Open

Disable dates in the future #2

siboscol opened this issue Sep 13, 2019 · 7 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@siboscol
Copy link

siboscol commented Sep 13, 2019

Hi,
amazing components, simple, straightforward and complete.
may I ask you if there is any way to disable dates in the future?
I'm not sure it's clear to me how to use endDate and startDate props.

@flippingbitss
Copy link
Owner

flippingbitss commented Sep 13, 2019

Hi @siboscol, thank you for using my component.

interface DateRangePickerProps {
	open: boolean;
	initialDateRange?: DateRange;
	definedRanges?: DefinedRange[];
	minDate?: Date | string;
	maxDate?: Date | string;
	onChange: (dateRange: DateRange) => void;
}

Above are the props taken by the picker, you can specify the minDate and maxDate prop and that will disable the dates outside of that range, it accepts both Date object and Date strings.

The component currently doesn't support disabling specific dates. Feel free to submit a PR or start a discussion in this thread.

@siboscol
Copy link
Author

Hi @matharumanpreet00 ,
Thanks a lot for your quick reply.
It works setting the minDate and maxDate!
I noticed that if I set up from 2002 until today I can see until 2004 as start year.
image

Is there a way to not see future years and allow user to select only past dates?

@flippingbitss
Copy link
Owner

I noticed that if I set up from 2002 until today I can see until 2004 as start year.

Yes, its a 30 year span in total with today at the mid. But that is something i would like to improve and make it respect minDate and maxDate props. I will be working towards this in the coming weeks.

Is there a way to not see future years and allow user to select only past dates?

For now, you could set maxDate as today and not set any minDate so that gives you max range. In the future versions, i will fix the years to respect these props.

Thanks.

@siboscol
Copy link
Author

Thanks a lot, very useful.
What I'm trying to do is to let user select a period in the past between today and 2002.
At the moment the only way to pick 2002 is to select 2004 and then reselect 2002.
I tried as well to not set any minDatebut then because of the default values on 10 years, I wouldn't be able to pick a date in 2002.
Anyway I really appreciate your effort in making date range respecting minDate and maxDate.
If there is anything I could do help you let me know.
Unfortunately I'm not proficient with typescript.

@flippingbitss
Copy link
Owner

No problem. If you like to try your hands on it, you can look at changing the signature of this function to accept minDate and maxDate.
JavaScript is valid TypeScript, so you can just use that if you like.

@flippingbitss flippingbitss added good first issue Good for newcomers bug Something isn't working labels Sep 18, 2019
@williamluke4
Copy link

What are peoples thoughts on adding a disabledRanges prop

interface DateRangePickerProps {
	open: boolean;
	initialDateRange?: DateRange;
	definedRanges?: DefinedRange[];
        disabledRanges?:DateRange[];
	minDate?: Date | string;
	maxDate?: Date | string;
	onChange: (dateRange: DateRange) => void;
}

@aemendoza072583
Copy link

How to disable a specific dates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants