Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Calendar): apply viewDate Year when yearNavigator and view month mode #7503

Merged
merged 6 commits into from
Dec 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,8 @@ export const Calendar = React.memo(
};

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

setCurrentYear(_currentYear);

Expand All @@ -493,7 +494,8 @@ export const Calendar = React.memo(
};

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

setCurrentYear(_currentYear);

Expand Down Expand Up @@ -1789,7 +1791,9 @@ export const Calendar = React.memo(

const onMonthSelect = (event, month) => {
if (props.view === 'month') {
onDateSelect(event, { year: currentYear, month: month, day: 1, selectable: true });
const year = getViewYear();

onDateSelect(event, { year, month: month, day: 1, selectable: true });
event.preventDefault();
} else {
setCurrentMonth(month);
Expand All @@ -1809,6 +1813,10 @@ export const Calendar = React.memo(
}
};

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

const onYearSelect = (event, year) => {
if (props.view === 'year') {
onDateSelect(event, { year: year, month: 0, day: 1, selectable: true });
Expand Down
Loading