Skip to content

Commit 39467c8

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.2-develop
Accepted Community Pull Requests: - #23086: [Backport] Fix wrong behavior of validation scroll (by @Den4ik) Fixed GitHub Issues: - #23034: Wrong behaviour of validation scroll (reported by @Den4ik) has been fixed in #23086 by @Den4ik in 2.2-develop branch Related commits: 1. 0820cd7
2 parents 73f2d45 + 3214013 commit 39467c8

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/web/mage/validation.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -990,8 +990,8 @@
990990
minValidRange = $.mage.parseNumber(validRange[1]);
991991
maxValidRange = $.mage.parseNumber(validRange[2]);
992992
result = result &&
993-
(isNaN(minValidRange) || minValue >= minValidRange) &&
994-
(isNaN(maxValidRange) || maxValue <= maxValidRange);
993+
(isNaN(minValidRange) || minValue >= minValidRange) &&
994+
(isNaN(maxValidRange) || maxValue <= maxValidRange);
995995
}
996996
}
997997

@@ -1109,8 +1109,8 @@
11091109
options = p.find('input');
11101110

11111111
return options.map(function (el) {
1112-
return $(el).val();
1113-
}).length > 0;
1112+
return $(el).val();
1113+
}).length > 0;
11141114
},
11151115
$.mage.__('Please select one of the options above.')
11161116
],
@@ -1922,15 +1922,15 @@
19221922
* @param {jQuery.Event} event
19231923
* @param {Object} validation
19241924
*/
1925-
listenFormValidateHandler: function (event, validation) {
1925+
listenFormValidateHandler: function (event, validation) {
19261926
var firstActive = $(validation.errorList[0].element || []),
19271927
lastActive = $(validation.findLastActive() ||
19281928
validation.errorList.length && validation.errorList[0].element || []),
1929-
parent, windowHeight, successList;
1929+
windowHeight = $(window).height(),
1930+
parent, successList;
19301931

19311932
if (lastActive.is(':hidden')) {
19321933
parent = lastActive.parent();
1933-
windowHeight = $(window).height();
19341934
$('html, body').animate({
19351935
scrollTop: parent.offset().top - windowHeight / 2
19361936
});
@@ -1948,8 +1948,8 @@
19481948
}
19491949

19501950
if (firstActive.length) {
1951-
$('html, body').stop().animate({
1952-
scrollTop: firstActive.offset().top
1951+
$('body').stop().animate({
1952+
scrollTop: firstActive.offset().top - windowHeight / 2
19531953
});
19541954
firstActive.focus();
19551955
}

0 commit comments

Comments
 (0)