Magento 2 - Do not scroll to invalid field on form validation
-
28-02-2021 - |
سؤال
On the log in page, when I don't input input in fields, the error message displays focusing on the invalid input. The window scrolls upto the invalid field at the same time.
I do not want the window to scroll. Where can I find the code for scrolling?
المحلول
copy MAGENTO_ROOT/vendor/magento/magento2-base/lib/web/mage/validation.js into app/design/frontend/THEME_ROOT/web/mage/
then comment (start in line 1956)
if (firstActive.length) {
$('html, body').animate({
scrollTop: firstActive.offset().top
});
firstActive.focus();
}
become
if (firstActive.length) {
/*$('html, body').animate({
scrollTop: firstActive.offset().top
});*/
firstActive.focus();
}
or just delete
if (firstActive.length) {
firstActive.focus();
}
لا تنتمي إلى magento.stackexchange