Skip to content

Commit

Permalink
fix: update viewYear according to getViewYear function
Browse files Browse the repository at this point in the history
  • Loading branch information
KumJungMin committed Dec 14, 2024
1 parent 9b7183f commit 4d667e3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,8 @@ export const Calendar = React.memo(
};

const decrementYear = () => {
const _currentYear = currentYear - 1;

const year = getViewYear();
const _currentYear = year - 1;
setCurrentYear(_currentYear);

if (props.yearNavigator && _currentYear < yearOptions[0]) {
Expand All @@ -493,7 +493,8 @@ export const Calendar = React.memo(
};

const incrementYear = () => {
const _currentYear = currentYear + 1;
const year = getViewYear();
const _currentYear = year + 1;

setCurrentYear(_currentYear);

Expand All @@ -506,6 +507,10 @@ export const Calendar = React.memo(
return _currentYear;
};

const getViewYear = () => {
return props.yearNavigator ? getViewDate().getFullYear() : currentYear;
};

const onMonthDropdownChange = (event, value) => {
const currentViewDate = getViewDate();
let newViewDate = cloneDate(currentViewDate);
Expand Down Expand Up @@ -1789,7 +1794,7 @@ export const Calendar = React.memo(

const onMonthSelect = (event, month) => {
if (props.view === 'month') {
const year = props.yearNavigator ? getViewDate().getFullYear() : currentYear;
const year = getViewYear();
onDateSelect(event, { year, month: month, day: 1, selectable: true });
event.preventDefault();
} else {
Expand Down

0 comments on commit 4d667e3

Please sign in to comment.