From 1be948ee2846b02e98e974568798ff275cf40cf3 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 5 May 2018 12:03:18 +1200 Subject: [PATCH] Scroll element into view if it's been moved off the screen --- interface/resources/html/raiseAndLowerKeyboard.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/interface/resources/html/raiseAndLowerKeyboard.js b/interface/resources/html/raiseAndLowerKeyboard.js index b2688e3db8..15df94334c 100644 --- a/interface/resources/html/raiseAndLowerKeyboard.js +++ b/interface/resources/html/raiseAndLowerKeyboard.js @@ -45,12 +45,15 @@ function scheduleBringToView(timeout) { setTimeout(function () { - // If the element is not visible because the keyboard has been raised over the top of it, scroll it into view. + // If the element is not visible because the keyboard has been raised over the top of it, scroll it up into view. + // If the element is not visible because the keyboard raising has moved it off screen, scroll it down into view. var elementRect = document.activeElement.getBoundingClientRect(); var VISUAL_MARGIN = 3 var delta = elementRect.y + elementRect.height + VISUAL_MARGIN - window.innerHeight; if (delta > 0) { window.scrollBy(0, delta); + } else if (elementRect.y < VISUAL_MARGIN) { + window.scrollBy(0, elementRect.y - VISUAL_MARGIN); } }, timeout); }