diff --git a/components/lib/calendar/Calendar.js b/components/lib/calendar/Calendar.js index d17a2019b8..12ec5d8a38 100644 --- a/components/lib/calendar/Calendar.js +++ b/components/lib/calendar/Calendar.js @@ -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( {