From e4ec093c41f9009f9d1b6abd7c053f409b2c2bc1 Mon Sep 17 00:00:00 2001 From: Elliot Spall <132617474+PuppetFoam@users.noreply.github.com> Date: Wed, 26 Jun 2024 11:39:20 -0400 Subject: [PATCH 1/2] Update Calendar.js navForward / navBackward now calls onMonthChange (if defined). --- components/lib/calendar/Calendar.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/components/lib/calendar/Calendar.js b/components/lib/calendar/Calendar.js index f9cf68ace4..243436815b 100644 --- a/components/lib/calendar/Calendar.js +++ b/components/lib/calendar/Calendar.js @@ -361,11 +361,15 @@ export const Calendar = React.memo( if (currentView === 'date') { if (newViewDate.getMonth() === 0) { + const newYear = decrementYear(); + newViewDate.setMonth(11); - newViewDate.setFullYear(decrementYear()); + newViewDate.setFullYear(newYear); + props.onMonthChange && props.onMonthChange({ month: 11, year: newYear }); setCurrentMonth(11); } else { newViewDate.setMonth(newViewDate.getMonth() - 1); + props.onMonthChange && props.onMonthChange({ month: currentMonth - 1, year: currentYear }); setCurrentMonth((prevState) => prevState - 1); } } else if (currentView === 'month') { @@ -406,11 +410,15 @@ export const Calendar = React.memo( if (currentView === 'date') { if (newViewDate.getMonth() === 11) { + const newYear = incrementYear(); + newViewDate.setMonth(0); - newViewDate.setFullYear(incrementYear()); + newViewDate.setFullYear(newYear); + props.onMonthChange && props.onMonthChange({ month: 0, year: newYear }); setCurrentMonth(0); } else { newViewDate.setMonth(newViewDate.getMonth() + 1); + props.onMonthChange && props.onMonthChange({ month: currentMonth + 1, year: currentYear }); setCurrentMonth((prevState) => prevState + 1); } } else if (currentView === 'month') { From e4a98bb01412e843a7f978e7004119665fc4c722 Mon Sep 17 00:00:00 2001 From: Elliot Spall <132617474+PuppetFoam@users.noreply.github.com> Date: Wed, 26 Jun 2024 16:13:48 +0000 Subject: [PATCH 2/2] prettier fix --- components/lib/calendar/Calendar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/lib/calendar/Calendar.js b/components/lib/calendar/Calendar.js index 243436815b..1a64f6fd61 100644 --- a/components/lib/calendar/Calendar.js +++ b/components/lib/calendar/Calendar.js @@ -362,7 +362,7 @@ export const Calendar = React.memo( if (currentView === 'date') { if (newViewDate.getMonth() === 0) { const newYear = decrementYear(); - + newViewDate.setMonth(11); newViewDate.setFullYear(newYear); props.onMonthChange && props.onMonthChange({ month: 11, year: newYear }); @@ -411,7 +411,7 @@ export const Calendar = React.memo( if (currentView === 'date') { if (newViewDate.getMonth() === 11) { const newYear = incrementYear(); - + newViewDate.setMonth(0); newViewDate.setFullYear(newYear); props.onMonthChange && props.onMonthChange({ month: 0, year: newYear });