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

Range error when selectedRange smaller or larger than validatedRange #18

Open
RonaldCY opened this issue Apr 15, 2021 · 0 comments
Open

Comments

@RonaldCY
Copy link

RonaldCY commented Apr 15, 2021

e.g.

(args: DateRangePickerWrapperProps) => {
  const initialDateRange = {
    startDate: addDays(new Date(), -3),
    endDate: addDays(new Date(), 3),
  }

  const definedRanges = [{
    label: "Default",
    startDate: addDays(new Date(), -3),
    endDate: addDays(new Date(), 3),
  }, {
    label: "Start of Month",
    startDate: startOfMonth(new Date()),
    endDate: addDays(startOfMonth(new Date()), 2),
  }, {
    label: "End of Month",
    startDate: addDays(endOfMonth(new Date()), -2),
    endDate: endOfMonth(new Date()),
  }]
  const  minDate = addDays(new Date(), -2);
  const maxDate = addDays(new Date(), 2);

  return (
    <DateRangePicker
      {...args}
      onChange={(r) => console.log(r)}
      initialDateRange={initialDateRange}
      definedRanges={definedRanges}
      minDate={minDate}
      maxDate={maxDate}
    />
  );
}

when I changed the minDate and maxDate validated out of range of the defined range, the range error will be come out

suggested sol on DateRangePicker.tsx @ ftn of setDateRangeValidated:

...
    if (newStart && newEnd && (newEnd >= minDateValid && newStart <= maxDateValid)) {
      if (newEnd >= minDateValid)
        range.startDate = newStart = max([newStart, minDateValid]);
      if (newStart <= maxDateValid)
        range.endDate = newEnd = min([newEnd, maxDateValid]);
...
@RonaldCY RonaldCY changed the title Range error when selectedRange smaller or larger validatedRange Range error when selectedRange smaller or larger than validatedRange Apr 15, 2021
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

1 participant