react-infinite-calendar icon indicating copy to clipboard operation
react-infinite-calendar copied to clipboard

Could handle Invalid date inputs better

Open offsky opened this issue 7 years ago • 2 comments

I experimented with passing invalid dates to InfiniteCalendar and found the following issues that we could improve upon

min={new Date("foo")} or max={new Date("foo")} In either of theses cases, the calendar is rendered totally blank.

selected={new Date("foo")} or selected={{start:new Date("foo"),end:end}} The calendar renders, but when you try to scroll or select a date, it crashes with an "Invalid offset NaN specified" error in the console.

It would be better to ignore the invalid dates I think.

offsky avatar Mar 08 '17 18:03 offsky

I stated this: https://github.com/Toodledo/react-infinite-calendar/commit/f2acae1636bb4293a1304a2ca3f1a67c35180f4a

Got it fixed for min/max, but not sure how to properly sanitize "selected" prop.

offsky avatar Mar 08 '17 19:03 offsky

Hey @offsky,

The sanitization logic for the selected prop is here: https://github.com/clauderic/react-infinite-calendar/blob/master/src/utils/index.js#L135

I think it should probably to default to selected={null} if the input is invalid

clauderic avatar Mar 10 '17 02:03 clauderic