fix: fix date picker second clear not trigger change event (#1438)

fix #1359
This commit is contained in:
iamkun 2021-02-08 16:06:40 +08:00 committed by GitHub
parent 82482a2076
commit 7170bdeacc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -207,9 +207,9 @@ export default defineComponent({
valueOnOpen.value = props.modelValue valueOnOpen.value = props.modelValue
} }
}) })
const emitChange = val => { const emitChange = (val, isClear) => {
// determine user real change only // determine user real change only
if (!valueEquals(val, valueOnOpen.value)) { if (isClear || !valueEquals(val, valueOnOpen.value)) {
ctx.emit('change', val) ctx.emit('change', val)
props.validateEvent && elFormItem.formItemMitt?.emit('el.form.change', val) props.validateEvent && elFormItem.formItemMitt?.emit('el.form.change', val)
} }
@ -322,7 +322,7 @@ export default defineComponent({
if (showClose.value) { if (showClose.value) {
event.stopPropagation() event.stopPropagation()
emitInput(null) emitInput(null)
emitChange(null) emitChange(null, true)
showClose.value = false showClose.value = false
pickerVisible.value = false pickerVisible.value = false
pickerOptions.value.handleClear && pickerOptions.value.handleClear() pickerOptions.value.handleClear && pickerOptions.value.handleClear()