From ebab021916e7fcdcef06adaddf3b5d68d97406e0 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Tue, 14 Apr 2020 23:00:19 +1000 Subject: [PATCH] Handle case when error input can't be found --- assets/javascripts/wizard/initializers/custom.js.es6 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/wizard/initializers/custom.js.es6 b/assets/javascripts/wizard/initializers/custom.js.es6 index d74e25b1..4f7d4646 100644 --- a/assets/javascripts/wizard/initializers/custom.js.es6 +++ b/assets/javascripts/wizard/initializers/custom.js.es6 @@ -90,9 +90,11 @@ export default { animateInvalidFields() { Ember.run.scheduleOnce('afterRender', () => { let query = '.invalid input[type=text], .invalid textarea, .invalid input[type=checkbox], .invalid .select-kit'; - + let $element = $(query); + let scrollTop = $(query).length ? $(query).offset().top - 200 : 0; + $([document.documentElement, document.body]).animate({ - scrollTop: $(query).offset().top - 200 + scrollTop }, 400, function() { $(query).wiggle(2, 100); });