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(DatePicker): highlight range of year in yearMode #5884

Merged
merged 1 commit into from
Jun 27, 2024
Merged
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
19 changes: 10 additions & 9 deletions packages/primevue/src/datepicker/DatePicker.vue
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -727,17 +727,18 @@ export default {
return false; return false;
}, },
isYearSelected(year) { isYearSelected(year) {
if (this.isComparable()) { if (!this.isComparable()) return false;
let value = this.isRangeSelection() ? this.modelValue[0] : this.modelValue;


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


return false; return start === year || end === year || (start < year && end > year);
} else {
return value.getFullYear() === year;
}
}, },
isDateEquals(value, dateMeta) { isDateEquals(value, dateMeta) {
if (value) return value.getDate() === dateMeta.day && value.getMonth() === dateMeta.month && value.getFullYear() === dateMeta.year; if (value) return value.getDate() === dateMeta.day && value.getMonth() === dateMeta.month && value.getFullYear() === dateMeta.year;
Expand Down
Loading