From 509292678dba35df97ab9179043ec80fe61df503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=B6nthal?= Date: Fri, 10 Sep 2021 05:49:33 +0200 Subject: [PATCH] fix(components): [el-form]: ensure form validation always triggers callback (#3294) ensures the callback is always called --- packages/components/form/src/form.vue | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/components/form/src/form.vue b/packages/components/form/src/form.vue index 30b9377bf6..27f6ed6ae4 100644 --- a/packages/components/form/src/form.vue +++ b/packages/components/form/src/form.vue @@ -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]) }