From: Sergei Izmailov Date: Sun, 28 Jun 2020 22:18:44 +0000 (+0300) Subject: Fix search input focus loose on autocompletion by tab X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=8cdede38258fe676b0378aa89a400d2cf239dd7e;p=blog.git Fix search input focus loose on autocompletion by tab --- 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') {