mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-21 01:02:59 +08:00
fix: [el-calendar] selected wrong date when change the month/year (#5297)
This commit is contained in:
parent
2606778d30
commit
1f71d3c80c
@ -156,4 +156,21 @@ describe('Calendar.vue', () => {
|
||||
expect((firstRow.firstElementChild as HTMLElement).innerHTML).toContain('3')
|
||||
expect((firstRow.lastElementChild as HTMLElement).innerHTML).toContain('9')
|
||||
})
|
||||
|
||||
it('click previous month or next month', async () => {
|
||||
const wrapper = _mount(
|
||||
`
|
||||
<el-calendar v-model="value"></el-calendar>
|
||||
`,
|
||||
() => ({ value: new Date('2019-04-01') })
|
||||
)
|
||||
await nextTick()
|
||||
const btns = wrapper.findAll('.el-button')
|
||||
const prevBtn = btns.at(0)
|
||||
const nextBtn = btns.at(2)
|
||||
await prevBtn.trigger('click')
|
||||
expect(wrapper.find('.is-selected').text()).toBe('1')
|
||||
await nextBtn.trigger('click')
|
||||
expect(wrapper.find('.is-selected').text()).toBe('1')
|
||||
})
|
||||
})
|
||||
|
@ -83,22 +83,22 @@ export default defineComponent({
|
||||
const now = dayjs().locale(lang.value)
|
||||
|
||||
const prevMonthDayjs = computed(() => {
|
||||
return date.value.subtract(1, 'month')
|
||||
return date.value.subtract(1, 'month').date(1)
|
||||
})
|
||||
const curMonthDatePrefix = computed(() => {
|
||||
return dayjs(date.value).locale(lang.value).format('YYYY-MM')
|
||||
})
|
||||
|
||||
const nextMonthDayjs = computed(() => {
|
||||
return date.value.add(1, 'month')
|
||||
return date.value.add(1, 'month').date(1)
|
||||
})
|
||||
|
||||
const prevYearDayjs = computed(() => {
|
||||
return date.value.subtract(1, 'year')
|
||||
return date.value.subtract(1, 'year').date(1)
|
||||
})
|
||||
|
||||
const nextYearDayjs = computed(() => {
|
||||
return date.value.add(1, 'year')
|
||||
return date.value.add(1, 'year').date(1)
|
||||
})
|
||||
|
||||
const i18nDate = computed(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user