From abce492efd2c7492a3245fc9bfde5a36e6d81410 Mon Sep 17 00:00:00 2001 From: melloware Date: Wed, 3 Apr 2024 07:42:12 -0400 Subject: [PATCH] Fix #6285: Calendar multiple months with yearNavigator --- components/doc/calendar/multiplemonthsdoc.js | 8 ++++---- components/lib/calendar/Calendar.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/doc/calendar/multiplemonthsdoc.js b/components/doc/calendar/multiplemonthsdoc.js index c80fbb6832..c85f7e86b9 100644 --- a/components/doc/calendar/multiplemonthsdoc.js +++ b/components/doc/calendar/multiplemonthsdoc.js @@ -8,7 +8,7 @@ export function MultipleMonthsDoc(props) { const code = { basic: ` - setDate(e.value)} numberOfMonths={2} /> + setDate(e.value)} numberOfMonths={3} /> `, javascript: ` import React, { useState } from "react"; @@ -19,7 +19,7 @@ export default function MultipleMonthsDemo() { return (
- setDate(e.value)} numberOfMonths={2} /> + setDate(e.value)} numberOfMonths={3} />
) } @@ -34,7 +34,7 @@ export default function MultipleMonthsDemo() { return (
- setDate(e.value)} numberOfMonths={2} /> + setDate(e.value)} numberOfMonths={3} />
) } @@ -49,7 +49,7 @@ export default function MultipleMonthsDemo() {

- setDate(e.value)} numberOfMonths={2} /> + setDate(e.value)} numberOfMonths={3} />
diff --git a/components/lib/calendar/Calendar.js b/components/lib/calendar/Calendar.js index 73e56920ea..4b28434ec2 100644 --- a/components/lib/calendar/Calendar.js +++ b/components/lib/calendar/Calendar.js @@ -3238,6 +3238,7 @@ export const Calendar = React.memo( const createTitleYearElement = (metaYear) => { const viewDate = getViewDate(); const viewYear = viewDate.getFullYear(); + const displayYear = props.numberOfMonths > 1 ? metaYear : currentYear; if (props.yearNavigator) { let yearOptions = []; @@ -3263,7 +3264,7 @@ export const Calendar = React.memo( { className: cx('select'), onChange: (e) => onYearDropdownChange(e, e.target.value), - value: viewYear + value: displayYear }, ptm('select') ); @@ -3305,7 +3306,6 @@ export const Calendar = React.memo( return content; } - const displayYear = props.numberOfMonths > 1 ? metaYear : currentYear; const yearTitleProps = mergeProps( { className: cx('yearTitle'),