From 170bbde0e924d6253294dfd3481658bdcb0f8c48 Mon Sep 17 00:00:00 2001 From: voidst1 Date: Tue, 15 Mar 2022 14:00:05 +0800 Subject: [PATCH] fix: Fixed bug #123\nreverseYears prop should only reverse the order in years overlay and months overlay should be unaffected --- src/Vue3DatePicker/components/MonthYearInput.vue | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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(() => {