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 #6285: Calendar multiple months with yearNavigator #6294

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions components/doc/calendar/multiplemonthsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function MultipleMonthsDoc(props) {

const code = {
basic: `
<Calendar value={date} onChange={(e) => setDate(e.value)} numberOfMonths={2} />
<Calendar value={date} onChange={(e) => setDate(e.value)} numberOfMonths={3} />
`,
javascript: `
import React, { useState } from "react";
Expand All @@ -19,7 +19,7 @@ export default function MultipleMonthsDemo() {

return (
<div className="card flex justify-content-center">
<Calendar value={date} onChange={(e) => setDate(e.value)} numberOfMonths={2} />
<Calendar value={date} onChange={(e) => setDate(e.value)} numberOfMonths={3} />
</div>
)
}
Expand All @@ -34,7 +34,7 @@ export default function MultipleMonthsDemo() {

return (
<div className="card flex justify-content-center">
<Calendar value={date} onChange={(e) => setDate(e.value)} numberOfMonths={2} />
<Calendar value={date} onChange={(e) => setDate(e.value)} numberOfMonths={3} />
</div>
)
}
Expand All @@ -49,7 +49,7 @@ export default function MultipleMonthsDemo() {
</p>
</DocSectionText>
<div className="card flex justify-content-center">
<Calendar value={date} onChange={(e) => setDate(e.value)} numberOfMonths={2} />
<Calendar value={date} onChange={(e) => setDate(e.value)} numberOfMonths={3} />
</div>
<DocSectionCode code={code} />
</>
Expand Down
4 changes: 2 additions & 2 deletions components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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')
);
Expand Down Expand Up @@ -3305,7 +3306,6 @@ export const Calendar = React.memo(
return content;
}

const displayYear = props.numberOfMonths > 1 ? metaYear : currentYear;
const yearTitleProps = mergeProps(
{
className: cx('yearTitle'),
Expand Down
Loading