diff --git a/src/Vue3DatePicker/components/MonthYearInput.vue b/src/Vue3DatePicker/components/MonthYearInput.vue index 41cc42c..cbe6cf8 100644 --- a/src/Vue3DatePicker/components/MonthYearInput.vue +++ b/src/Vue3DatePicker/components/MonthYearInput.vue @@ -243,14 +243,14 @@ return props.range && props.internalModelValue && props.monthPicker ? (props.internalModelValue as Date[]) : []; }); - const getGroupedList = (items: IDefaultSelect[]): IDefaultSelect[][] => { + const getGroupedList = (items: IDefaultSelect[], reverse: Boolean = false): IDefaultSelect[][] => { const list = []; for (let i = 0; i < items.length; i += 3) { const listItems = [items[i], items[i + 1], items[i + 2]]; - list.push(props.reverseYears ? listItems.reverse() : listItems); + list.push(reverse ? listItems.reverse() : listItems); } - return list; + return reverse ? list.reverse() : list; }; const getMonthDisplayVal = computed((): IDefaultSelect => { @@ -264,8 +264,7 @@ }); const groupedYears = computed((): IDefaultSelect[][] => { - const list = getGroupedList(props.years); - return props.reverseYears ? list.reverse() : list; + return getGroupedList(props.years, props.reverseYears); }); const showLeftIcon = computed(() => {