Skip to content

Commit

Permalink
ENGCOM-5197: [Backport] Fix wrong behavior of validation scroll #23086
Browse files Browse the repository at this point in the history
  • Loading branch information
p-bystritsky committed Jun 3, 2019
2 parents 73f2d45 + 31bd492 commit 3214013
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/web/mage/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -990,8 +990,8 @@
minValidRange = $.mage.parseNumber(validRange[1]);
maxValidRange = $.mage.parseNumber(validRange[2]);
result = result &&
(isNaN(minValidRange) || minValue >= minValidRange) &&
(isNaN(maxValidRange) || maxValue <= maxValidRange);
(isNaN(minValidRange) || minValue >= minValidRange) &&
(isNaN(maxValidRange) || maxValue <= maxValidRange);
}
}

Expand Down Expand Up @@ -1109,8 +1109,8 @@
options = p.find('input');

return options.map(function (el) {
return $(el).val();
}).length > 0;
return $(el).val();
}).length > 0;
},
$.mage.__('Please select one of the options above.')
],
Expand Down Expand Up @@ -1922,15 +1922,15 @@
* @param {jQuery.Event} event
* @param {Object} validation
*/
listenFormValidateHandler: function (event, validation) {
listenFormValidateHandler: function (event, validation) {
var firstActive = $(validation.errorList[0].element || []),
lastActive = $(validation.findLastActive() ||
validation.errorList.length && validation.errorList[0].element || []),
parent, windowHeight, successList;
windowHeight = $(window).height(),
parent, successList;

if (lastActive.is(':hidden')) {
parent = lastActive.parent();
windowHeight = $(window).height();
$('html, body').animate({
scrollTop: parent.offset().top - windowHeight / 2
});
Expand All @@ -1948,8 +1948,8 @@
}

if (firstActive.length) {
$('html, body').stop().animate({
scrollTop: firstActive.offset().top
$('body').stop().animate({
scrollTop: firstActive.offset().top - windowHeight / 2
});
firstActive.focus();
}
Expand Down

0 comments on commit 3214013

Please sign in to comment.