From 7986e57036d27df0fa6b0b51cc42c59d9447758e Mon Sep 17 00:00:00 2001 From: Jack Date: Sat, 24 Oct 2020 22:45:46 +0100 Subject: [PATCH] catching the scrolling error --- public/js/commandline.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/public/js/commandline.js b/public/js/commandline.js index 337501f86..f33dc480a 100644 --- a/public/js/commandline.js +++ b/public/js/commandline.js @@ -1691,15 +1691,19 @@ $(document).keydown((e) => { hoverId = $(entries[activenum]).attr("command"); } } - let scroll = - Math.abs( - $(".suggestions").offset().top - + try { + let scroll = + Math.abs( + $(".suggestions").offset().top - $(".entry.activeKeyboard").offset().top - $(".suggestions").scrollTop() - ) - - $(".suggestions").outerHeight() / 2 + - $($(".entry")[0]).outerHeight(); - $(".suggestions").scrollTop(scroll); + ) - + $(".suggestions").outerHeight() / 2 + + $($(".entry")[0]).outerHeight(); + $(".suggestions").scrollTop(scroll); + } catch (e) { + console.log('could not scroll suggestions: ' + e.message); + } // console.log(`scrolling to ${scroll}`); try { let list = currentCommands[currentCommands.length - 1];