Skip to content

Commit

Permalink
Fix primefaces#5973: Calendar yearNavigator defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Feb 15, 2024
1 parent 77eecd3 commit d15cc67
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3172,18 +3172,28 @@ export const Calendar = React.memo(
};

const createTitleYearElement = (metaYear) => {
const viewDate = getViewDate();
const viewYear = viewDate.getFullYear();

if (props.yearNavigator) {
let yearOptions = [];
const years = props.yearRange.split(':');
const yearStart = parseInt(years[0], 10);
const yearEnd = parseInt(years[1], 10);

for (let i = yearStart; i <= yearEnd; i++) {
yearOptions.push(i);
if (props.yearRange) {
const years = props.yearRange.split(':');
const yearStart = parseInt(years[0], 10);
const yearEnd = parseInt(years[1], 10);

for (let i = yearStart; i <= yearEnd; i++) {
yearOptions.push(i);
}
} else {
const base = viewYear - (viewYear % 10);

for (let i = 0; i < 10; i++) {
yearOptions.push(base + i);
}
}

const viewDate = getViewDate();
const viewYear = viewDate.getFullYear();
const displayedYearNames = yearOptions.filter((year) => !(props.minDate && props.minDate.getFullYear() > year) && !(props.maxDate && props.maxDate.getFullYear() < year));
const selectProps = mergeProps(
{
Expand Down

0 comments on commit d15cc67

Please sign in to comment.