Skip to content

Commit

Permalink
fix: apply year change in Calendar when input changed (#6794)
Browse files Browse the repository at this point in the history
  • Loading branch information
KumJungMin committed Jun 26, 2024
1 parent da22444 commit 0c155da
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3070,29 +3070,29 @@ export const Calendar = React.memo(
isTypingRef.current = false;

// #3516 view date not updated when value set programatically
if (!visible && newDate) {
let viewDate = newDate;
if (!newDate) return;

if (isMultipleSelection()) {
if (newDate.length) {
viewDate = newDate[newDate.length - 1];
}
} else if (isRangeSelection()) {
if (newDate.length) {
let startDate = newDate[0];
let endDate = newDate[1];
let viewDate = newDate;

viewDate = endDate || startDate;
}
if (isMultipleSelection()) {
if (newDate.length) {
viewDate = newDate[newDate.length - 1];
}
} else if (isRangeSelection()) {
if (newDate.length) {
let startDate = newDate[0];
let endDate = newDate[1];

if (viewDate instanceof Date) {
validateDate(viewDate);
setViewDateState(viewDate);
setCurrentMonth(viewDate.getMonth());
setCurrentYear(viewDate.getFullYear());
viewDate = endDate || startDate;
}
}

if (viewDate instanceof Date) {
validateDate(viewDate);
setViewDateState(viewDate);
setCurrentMonth(viewDate.getMonth());
setCurrentYear(viewDate.getFullYear());
}
}
}, [props.value, visible]);

Expand Down

0 comments on commit 0c155da

Please sign in to comment.