How to scroll to field with input error after submit? #3835
-
Hello! In vee-validate 3 it was possible to set a And each error had an
There is no I searched for my problem in the discussions, but to my surprise I did not find it. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The docs doesn't really discourage you from using In v4 there is a concept of invalid submissions with that you could easily implement scroll behavior. function onInvalidSubmit({ values, errors, results }) {
const firstErrorFieldName = Object.keys(errors)[0];
const el = document.querySelector(`[name="${firstErrorFieldName}"]`);
if (el) {
el.scrollIntoView();
}
} |
Beta Was this translation helpful? Give feedback.
The docs doesn't really discourage you from using
refs
if they work for you then sure. They only discourage it for doing form actions.In v4 there is a concept of invalid submissions with that you could easily implement scroll behavior.