mirror of
https://github.com/element-plus/element-plus.git
synced 2026-02-04 10:33:11 +08:00
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:
@@ -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)
|
||||
|
||||
@@ -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')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user