Skip to content

Commit

Permalink
fix(form): should scroll into first invalid field
Browse files Browse the repository at this point in the history
  • Loading branch information
dolymood committed Oct 18, 2019
1 parent e7a85a2 commit c46d471
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/components/form/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@
this.$emit(EVENT_VALID, this.validity)
this.$emit(EVENT_SUBMIT, e, this.model, this.fieldsModel)
} else {
// scrollToInvalidField
if (this.options.scrollToInvalidField && this.firstInvalidField) {
this.firstInvalidField.$el.scrollIntoView()
}
e.preventDefault()
this.$emit(EVENT_INVALID, this.validity)
}
Expand All @@ -164,11 +168,6 @@
},
_submit(cb) {
this.validate(() => {
if (this.invalid) {
if (this.options.scrollToInvalidField && this.firstInvalidField) {
this.firstInvalidField.$el.scrollIntoView()
}
}
cb && cb(this.valid)
})
},
Expand Down

0 comments on commit c46d471

Please sign in to comment.