@@ -76,8 +76,9 @@ document.getElementById("searchInput").onkeyup = function (e) {
7676document . onkeydown = function ( e ) {
7777 let key = e . key ;
7878 let ae = document . activeElement ;
79+ let inbox = document . getElementById ( "searchbox" ) . contains ( ae )
7980
80- if ( key === "ArrowDown" && resultsAvailable ) {
81+ if ( key === "ArrowDown" && resultsAvailable && inbox ) {
8182 e . preventDefault ( ) ;
8283 if ( ae == sInput ) {
8384 // if the currently focused element is the search input, focus the <a> of first <li>
@@ -92,7 +93,7 @@ document.onkeydown = function (e) {
9293 ae . parentElement . nextSibling . lastChild . focus ( ) ;
9394 activeToggle ( ) ; // add active class
9495 }
95- } else if ( key === "ArrowUp" && resultsAvailable ) {
96+ } else if ( key === "ArrowUp" && resultsAvailable && inbox ) {
9697 e . preventDefault ( ) ;
9798 if ( ae == sInput ) {
9899 // if the currently focused element is input box, do nothing
@@ -106,17 +107,11 @@ document.onkeydown = function (e) {
106107 ae . parentElement . previousSibling . lastChild . focus ( ) ;
107108 activeToggle ( ) ; // add active class
108109 }
109- } else if ( key === "ArrowRight" && resultsAvailable ) {
110+ } else if ( key === "ArrowRight" && resultsAvailable && inbox ) {
110111 ae . click ( ) ; // click on active link
111112 } else if ( key === "Escape" ) {
112113 resultsAvailable = false ;
113114 document . getElementById ( "searchResults" ) . innerHTML = sInput . value = '' ; // clear inputbox and searchResults
114115 sInput . focus ( ) ; // shift focus to input box
115116 }
116117}
117-
118- document . onmousedown = function ( e ) {
119- if ( e . type === "mousedown" ) {
120- e . preventDefault ( ) ; // prevent mousedown to change focus
121- }
122- }
0 commit comments