Skip to content

Commit 5b01913

Browse files
committed
[Validator] Fix wrong behavior of validation scroll
1 parent 15100ac commit 5b01913

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

@@ -1115,8 +1115,8 @@
11151115
options = p.find('input');
11161116

11171117
return options.map(function (el) {
1118-
return $(el).val();
1119-
}).length > 0;
1118+
return $(el).val();
1119+
}).length > 0;
11201120
},
11211121
$.mage.__('Please select one of the options above.')
11221122
],
@@ -1932,15 +1932,15 @@
19321932
* @param {jQuery.Event} event
19331933
* @param {Object} validation
19341934
*/
1935-
listenFormValidateHandler: function (event, validation) {
1935+
listenFormValidateHandler: function (event, validation) {
19361936
var firstActive = $(validation.errorList[0].element || []),
19371937
lastActive = $(validation.findLastActive() ||
19381938
validation.errorList.length && validation.errorList[0].element || []),
1939-
parent, windowHeight, successList;
1939+
windowHeight = $(window).height(),
1940+
parent, successList;
19401941

19411942
if (lastActive.is(':hidden')) {
19421943
parent = lastActive.parent();
1943-
windowHeight = $(window).height();
19441944
$('html, body').animate({
19451945
scrollTop: parent.offset().top - windowHeight / 2
19461946
});
@@ -1958,8 +1958,8 @@
19581958
}
19591959

19601960
if (firstActive.length) {
1961-
$('html, body').stop().animate({
1962-
scrollTop: firstActive.offset().top
1961+
$('body').stop().animate({
1962+
scrollTop: firstActive.offset().top - windowHeight / 2
19631963
});
19641964
firstActive.focus();
19651965
}

0 commit comments

Comments
 (0)