chiark / gitweb /
Fix search input focus loose on autocompletion by tab
authorSergei Izmailov <sergei.a.izmailov@gmail.com>
Sun, 28 Jun 2020 22:18:44 +0000 (01:18 +0300)
committerVladimír Vondruš <mosra@centrum.cz>
Thu, 8 Oct 2020 11:11:01 +0000 (13:11 +0200)
documentation/search.js

index 56ba52fe0102837a28c8def67e3bb2838820e911..5346fa632922fb3933d022f62540e0ebcd366f4a 100644 (file)
@@ -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') {