From df6630f86898cd6ae1bca7b9b9ed1e3b27cc0468 Mon Sep 17 00:00:00 2001 From: Dan Ungureanu Date: Fri, 16 Aug 2019 17:28:25 +0300 Subject: [PATCH] FIX: J/K navigation resets current selection when scrolling fast. Sometimes, when keeping J or K pressed and scrolling fast, the current selection would go out of the viewport for a few moments and the algorithm would try selecting the "best" element that is in viewport. This bug is reproducible only on certain machines. For example, Linux machines seem to be passing key events faster to the browser. --- app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 index 5e0a3996ea3..664a1cbdc6a 100644 --- a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 +++ b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 @@ -441,7 +441,7 @@ export default { // Discard selection if it is not in viewport, so users can combine // keyboard shortcuts with mouse scrolling. - if ($selected.length !== 0) { + if ($selected.length !== 0 && !fast) { const offset = minimumOffset(); const beginScreen = $(window).scrollTop() - offset; const endScreen = beginScreen + window.innerHeight + offset;