Skip to content

Commit e8491b3

Browse files
authored
Merge pull request #1155 from mayswind/main
Fix missing value and text props in year slot when using the month picker
2 parents 292b7c0 + f498b82 commit e8491b3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/VueDatePicker/components/shared/YearModePicker.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
@click="() => toggleYearPicker(false)"
2121
@keydown.enter="() => toggleYearPicker(false)"
2222
>
23-
<slot v-if="$slots.year" name="year" :year="year" />
24-
<template v-if="!$slots.year">{{ year }}</template>
23+
<slot v-if="$slots.year" name="year" :year="year" :text="yearDisplayVal" :value="year" />
24+
<template v-if="!$slots.year">{{ yearDisplayVal }}</template>
2525
</button>
2626
<ArrowBtn
2727
v-if="showRightIcon(defaultedMultiCalendars, instance)"
@@ -69,7 +69,8 @@
6969
import { useCommon, useDefaults, useTransitions } from '@/composables';
7070
import { PickerBaseProps } from '@/props';
7171
72-
import { type PropType, ref } from 'vue';
72+
import { type PropType, ref, computed } from 'vue';
73+
import { formatNumber } from '@/utils/util';
7374
import type { OverlayGridItem } from '@/interfaces';
7475
7576
const emit = defineEmits(['toggle-year-picker', 'year-select', 'handle-year']);
@@ -89,6 +90,8 @@
8990
9091
const overlayOpen = ref(false);
9192
93+
const yearDisplayVal = computed((): string => formatNumber(props.year, props.locale));
94+
9295
const toggleYearPicker = (flow = false, show?: boolean) => {
9396
overlayOpen.value = !overlayOpen.value;
9497
emit('toggle-year-picker', { flow, show });

0 commit comments

Comments
 (0)