fix(components): [date-picker] time list sync with input change (#22589)

* fix(components): [date-picker] time list sync with input change

closed #22500

* test: add test case
This commit is contained in:
Noblet Ouways
2025-10-27 08:27:50 +01:00
committed by GitHub
parent d39ecebe75
commit 35dbfbf98a
2 changed files with 22 additions and 0 deletions

View File

@@ -792,6 +792,7 @@ const handleTimeInput = (value: string | null, type: ChangeType) => {
.hour(parsedValueD.hour())
.minute(parsedValueD.minute())
.second(parsedValueD.second())
leftDate.value = minDate.value
} else {
maxTimePickerVisible.value = true
maxDate.value = (maxDate.value || rightDate.value)

View File

@@ -1198,4 +1198,25 @@ describe('Datetimerange', () => {
await wrapper.find('.el-date-editor').trigger('click')
expect(onUpdateModelValue).not.toHaveBeenCalled()
})
it('should left list time be sync with input input change', async () => {
const modelValue = ['2025-09-01', '2025-09-07']
const wrapper = _mount(() => (
<DatePicker modelValue={modelValue} type="datetimerange" />
))
const input = wrapper.find('input')
await input.trigger('blur')
await input.trigger('focus')
const leftTimeInput = document.querySelectorAll<HTMLInputElement>(
'.el-date-range-picker__time-picker-wrap input'
)[1]
leftTimeInput.value = 'AM 12:00:01'
triggerEvent(leftTimeInput, 'input')
await nextTick()
expect(
document.querySelectorAll('.el-time-spinner__list .is-active')[2]
.textContent
).toBe('01')
})
})