Skip to content

Commit

Permalink
Merge pull request #68 from denislorch/feature/focus-validation
Browse files Browse the repository at this point in the history
[FEATURE] Improve scrollToFirstError behavior
  • Loading branch information
mschwemer authored Feb 2, 2024
2 parents d7fbf5d + 18f4fdd commit 81fa13a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Resources/Private/Build/JavaScript/FormValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ class Form {
const fieldsWithError = this.#form.querySelectorAll('.powermail_field_error');
fieldsWithError.forEach((field) => {
if (Utility.isElementVisible(field)) {
field.scrollIntoView({behavior:'smooth'});
field.scrollIntoView({behavior:'smooth', block:'center'});
field.focus({preventScroll:true});
throw 'StopException';
}
});
Expand Down

0 comments on commit 81fa13a

Please sign in to comment.