Skip to content

Commit

Permalink
Fix #3515: Calendar fix controlled value change
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Oct 28, 2022
1 parent ea8aa17 commit 20fd559
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2489,8 +2489,18 @@ export const Calendar = React.memo(
}, [props.onViewDateChange, props.value]);

useUpdateEffect(() => {
if (previousValue !== props.value && (!viewStateChanged.current || visible)) {
updateInputfield(props.value);
const newDate = props.value;

if (previousValue !== newDate) {
updateInputfield(newDate);

// #3516 view date not updated when value set programatically
if (!visible && newDate) {
validateDate(newDate);
setViewDateState(newDate);
setCurrentMonth(newDate.getMonth());
setCurrentYear(newDate.getFullYear());
}
}
}, [props.value, visible]);

Expand Down

0 comments on commit 20fd559

Please sign in to comment.