mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-02 19:28:14 +08:00
fix(components): [el-form]: ensure form validation always triggers callback (#3294)
ensures the callback is always called
This commit is contained in:
parent
6db8dbca82
commit
509292678d
@ -184,7 +184,6 @@ export default defineComponent({
|
||||
callback(true)
|
||||
}
|
||||
let valid = true
|
||||
let count = 0
|
||||
let invalidFields = {}
|
||||
let firstInvalidFields
|
||||
for (const field of fields) {
|
||||
@ -194,11 +193,10 @@ export default defineComponent({
|
||||
firstInvalidFields || (firstInvalidFields = field)
|
||||
}
|
||||
invalidFields = { ...invalidFields, ...field }
|
||||
if (++count === fields.length) {
|
||||
callback(valid, invalidFields)
|
||||
}
|
||||
})
|
||||
}
|
||||
callback(valid, invalidFields)
|
||||
|
||||
if (!valid && props.scrollToError) {
|
||||
scrollToField(Object.keys(firstInvalidFields)[0])
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user