diff --git a/components/lib/calendar/Calendar.js b/components/lib/calendar/Calendar.js index 3d8ce62e8e..3766153059 100644 --- a/components/lib/calendar/Calendar.js +++ b/components/lib/calendar/Calendar.js @@ -2496,10 +2496,27 @@ export const Calendar = React.memo( // #3516 view date not updated when value set programatically if (!visible && newDate) { - validateDate(newDate); - setViewDateState(newDate); - setCurrentMonth(newDate.getMonth()); - setCurrentYear(newDate.getFullYear()); + let viewDate; + + if (isSingleSelection()) { + viewDate = newDate; + } else if (isMultipleSelection()) { + if (newDate.length) { + viewDate = newDate[newDate.length - 1]; + } + } else if (isRangeSelection()) { + if (newDate.length) { + let startDate = newDate[0]; + let endDate = newDate[1]; + + viewDate = endDate || startDate; + } + } + + validateDate(viewDate); + setViewDateState(viewDate); + setCurrentMonth(viewDate.getMonth()); + setCurrentYear(viewDate.getFullYear()); } } }, [props.value, visible]);