From 8cdede38258fe676b0378aa89a400d2cf239dd7e Mon Sep 17 00:00:00 2001 From: Sergei Izmailov Date: Mon, 29 Jun 2020 01:18:44 +0300 Subject: [PATCH] Fix search input focus loose on autocompletion by tab --- documentation/search.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/documentation/search.js b/documentation/search.js index 56ba52fe..5346fa63 100644 --- a/documentation/search.js +++ b/documentation/search.js @@ -666,8 +666,10 @@ if(typeof document !== 'undefined') { } else if(event.key == 'Tab' && !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey) { /* But only if the input has selection at the end */ let input = document.getElementById('search-input'); - if(input.selectionEnd == input.value.length && input.selectionStart != input.selectionEnd) + if(input.selectionEnd == input.value.length && input.selectionStart != input.selectionEnd) { input.setSelectionRange(input.value.length, input.value.length); + return false; /* so input won't lose focus */ + } /* Select next item */ } else if(event.key == 'ArrowDown') { -- 2.30.2