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:
betavs
2024-02-28 12:09:47 +08:00
committed by GitHub
parent 9ef20c6d6a
commit 0e1f6ffaa0
2 changed files with 18 additions and 3 deletions

View File

@@ -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', () => {

View File

@@ -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)