mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
fix(components): [date-picker] selected value comparison logic error (#15918)
* fix(components): [date-picker] selected value comparison logic error * test(components): [date-picker] selected value comparison logic error * perf(components): [date-picker] selected value comparison logic error Co-authored-by: kooriookami <38392315+kooriookami@users.noreply.github.com> --------- Co-authored-by: kooriookami <38392315+kooriookami@users.noreply.github.com>
This commit is contained in:
@@ -1006,6 +1006,23 @@ describe('DatePicker dates', () => {
|
||||
await nextTick()
|
||||
expect(vm.value.length).toBe(0)
|
||||
})
|
||||
|
||||
it('selected', async () => {
|
||||
const wrapper = _mount(
|
||||
`<el-date-picker
|
||||
type="dates"
|
||||
v-model="value"
|
||||
/>`,
|
||||
() => ({ value: [new Date()] })
|
||||
)
|
||||
const input = wrapper.find('input')
|
||||
input.trigger('blur')
|
||||
input.trigger('focus')
|
||||
await nextTick()
|
||||
expect(
|
||||
document.querySelectorAll('.el-date-table__row .selected').length
|
||||
).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('DatePicker keyboard events', () => {
|
||||
|
||||
@@ -133,9 +133,7 @@ export const useBasicDateTable = (
|
||||
const shouldIncrement = setDateText(cell, { count, rowIndex, columnIndex })
|
||||
|
||||
const cellDate = cell.dayjs!.toDate()
|
||||
cell.selected = _selectedDate.find(
|
||||
(d) => d.valueOf() === cell.dayjs!.valueOf()
|
||||
)
|
||||
cell.selected = _selectedDate.find((d) => d.isSame(cell.dayjs, 'day'))
|
||||
cell.isSelected = !!cell.selected
|
||||
cell.isCurrent = isCurrent(cell)
|
||||
cell.disabled = disabledDate?.(cellDate)
|
||||
|
||||
Reference in New Issue
Block a user