Skip to content

Commit

Permalink
fix: highlight range of year in datePicker (primefaces#6760)
Browse files Browse the repository at this point in the history
  • Loading branch information
KumJungMin authored Jun 14, 2024
1 parent 8899b5f commit 2a8001f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2354,17 +2354,18 @@ export const Calendar = React.memo(
};

const isYearSelected = (year) => {
if (isComparable()) {
let value = isRangeSelection() ? props.value[0] : props.value;
if (!isComparable()) return false;

if (isMultipleSelection()) {
return value.some((currentValue) => currentValue.getFullYear() === year);
}
if (isMultipleSelection()) {
return props.value.some((v) => v.getFullYear() === year);
} else if (isRangeSelection()) {
const start = props.value[0] ? props.value[0].getFullYear() : null;
const end = props.value[1] ? props.value[1].getFullYear() : null;

return value.getFullYear() === year;
return start === year || end === year || (start < year && end > year);
} else {
return props.value.getFullYear() === year;
}

return false;
};

const switchViewButtonDisabled = () => {
Expand Down

0 comments on commit 2a8001f

Please sign in to comment.