From 0e887175e00acd9d4b2b21f7916181ca24784a76 Mon Sep 17 00:00:00 2001 From: Shish Date: Fri, 29 Dec 2023 11:39:00 +0000 Subject: [PATCH] [autocomplete] allow keyboard to override an idle mouse --- ext/autocomplete/script.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ext/autocomplete/script.js b/ext/autocomplete/script.js index fa5c6e77..0926fd4c 100644 --- a/ext/autocomplete/script.js +++ b/ext/autocomplete/script.js @@ -101,8 +101,14 @@ function renderCompletions(element) { li.className = 'selected'; } // on hover, select the completion - li.addEventListener('mouseover', () => { - highlightCompletion(element, i); + // (use mousemove rather than mouseover, because + // if the mouse is stationary, then we want the + // keyboard to be able to override it) + li.addEventListener('mousemove', () => { + // avoid re-rendering if the completion is already selected + if(element.selected_completion !== i) { + highlightCompletion(element, i); + } }); // on click, set the completion // (mousedown is used instead of click because click is