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

onChange doesn't work with minDate and maxDate #308

Open
m-alnammas opened this issue Aug 19, 2024 · 3 comments
Open

onChange doesn't work with minDate and maxDate #308

m-alnammas opened this issue Aug 19, 2024 · 3 comments

Comments

@m-alnammas
Copy link

i'm building a custom form and i need to validate the user input when typing the date as well as when selecting.
the problem i'm facing is that the onChange function doesn't work when typing if i provide a minDate and a maxDate.
if i remove the minDate and maxDate props and type the date the onChange works.
the onChange only works when the user input is within the min and max range.

@chrisbarm
Copy link

chrisbarm commented Aug 19, 2024

I'm having the same issue, when using Max Min date the onChange does not fire.

I am using the time selector along with the calendar.

I have the minDate set to now - 31 days. and the maxDate set to now.

if I select an hour less than the current hour and then select the minimum date the time selector is frozen I have to change the date to more than the minimum in order to change the time.

If the onchange fired as I would have expected I can then compare the time and set it to the current time and apply this to the minimum date time value.

Hope this makes sense

@Svartalheim
Copy link

Svartalheim commented Dec 6, 2024

my current solution was adding this code inside the datepicker props, (i have trouble when selecting monthpicker, with minDate, if the month is same as the minDate somehow the bug appears) which fixed in this code below

onPropsChange={(props: any) => { if (monthPickerOnly && props.value.month.index === today.getMonth()) { setDate(new Date()); if (onDateChange) onDateChange(new Date()); } }}

@dangthuaan
Copy link

dangthuaan commented Dec 20, 2024

set minDate to start of the day, and maxDate to end of the day resolved this issue, example:

const minDate = new DateObject(new Date(new Date('2024-01-01').setHours(0, 0, 0, 0)))
const maxDate = new DateObject(new Date(new Date().setHours(23, 59, 59, 999)))

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

4 participants