Skip to content

Commit

Permalink
Fix primefaces#6285: Calendar multiple months with yearNavigator
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Apr 3, 2024
1 parent 0a5071c commit abce492
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
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

0 comments on commit abce492

Please sign in to comment.