calendar icon indicating copy to clipboard operation
calendar copied to clipboard

Providing an array in selectedValue or defaultSelectedValue for rc-calendar

Open oskarleonard opened this issue 6 years ago • 1 comments

I want to select multiple dates programmatically since i have a "filter" for week view and day view. So when in week view i would like to select that whole week.

I tried to pass in an array of dates to selectedValue (as one can do for ´RangeCalendar) toCalendarand got an undocumented behavior. It seemed to select the dates in the arrat (not acting like a range), so if i passed inselectedValue={[moment("2019-02-16"), moment("2019-02-20")]}`, the dates 2019-02-16 and 2019-02-20 was selected (not the dates in between). This is all good and i can modify it to my needs using this prop, hover im getting

Warning: Failed prop type: Invalid prop `defaultSelectedValue` of type `array` supplied to `CalendarMixinWrapper`, expected `object`.

Which makes me think either this is not really supported and will lead to bugs

oskarleonard avatar Feb 19 '19 10:02 oskarleonard

@oskarleonard I don't know why you are getting that error without seeing more of your code, but to get the range selected, have you tried something like this?

const selectedStartDate = moment("2019-02-16")

...
selectedValue={[selectedStartDate, selectedStartDate.clone().add(7, 'days')]}
...

mdelrossi1 avatar Mar 10 '19 19:03 mdelrossi1