@@ -3009,27 +3009,27 @@ function initSearch(rawSearchIndex) {
30093009 async function addTab ( array , query , display ) {
30103010 const extraClass = display ? " active" : "" ;
30113011
3012- const output = document . createElement ( "div " ) ;
3012+ let output = document . createElement ( "ul " ) ;
30133013 if ( array . length > 0 ) {
30143014 output . className = "search-results " + extraClass ;
30153015
3016- const links = Promise . all ( array . map ( async item => {
3016+ const lis = Promise . all ( array . map ( async item => {
30173017 const name = item . name ;
30183018 const type = itemTypes [ item . ty ] ;
30193019 const longType = longItemTypes [ item . ty ] ;
30203020 const typeName = longType . length !== 0 ? `${ longType } ` : "?" ;
30213021
3022- const link = document . createElement ( "a" ) ;
3023- link . className = "result-" + type ;
3024- link . href = item . href ;
3022+ const li = document . createElement ( "li" ) ;
3023+ li . className = "result-" + type ;
30253024
3026- const resultName = document . createElement ( "div " ) ;
3025+ const resultName = document . createElement ( "a " ) ;
30273026 resultName . className = "result-name" ;
3027+ resultName . href = item . href ;
30283028
30293029 resultName . insertAdjacentHTML (
30303030 "beforeend" ,
30313031 `<span class="typename">${ typeName } </span>` ) ;
3032- link . appendChild ( resultName ) ;
3032+ li . appendChild ( resultName ) ;
30333033
30343034 let alias = " " ;
30353035 if ( item . is_alias ) {
@@ -3050,8 +3050,8 @@ ${item.displayPath}<span class="${type}">${name}</span>\
30503050 const displayType = document . createElement ( "div" ) ;
30513051 if ( mappedNames . size > 0 || whereClause . size > 0 ) {
30523052 const tooltip = document . createElement ( "a" ) ;
3053- tooltip . tabIndex = - 1 ;
30543053 tooltip . id = `tooltip-${ item . id } ` ;
3054+ tooltip . href = `#${ tooltip . id } ` ;
30553055 const tooltipCode = document . createElement ( "code" ) ;
30563056 for ( const [ name , qname ] of mappedNames ) {
30573057 const line = document . createElement ( "div" ) ;
@@ -3106,15 +3106,22 @@ ${item.displayPath}<span class="${type}">${name}</span>\
31063106 }
31073107 description . insertAdjacentHTML ( "beforeend" , item . desc ) ;
31083108
3109- link . appendChild ( description ) ;
3110- return link ;
3109+ li . appendChild ( description ) ;
3110+ li . tabIndex = - 1 ;
3111+ li . onclick = ( ) => {
3112+ // allow clicking anywhere on the list item to go to the page
3113+ // even though the link itself is only the name
3114+ resultName . click ( ) ;
3115+ } ;
3116+ return li ;
31113117 } ) ) ;
3112- links . then ( links => {
3113- for ( const link of links ) {
3114- output . appendChild ( link ) ;
3118+ lis . then ( lis => {
3119+ for ( const li of lis ) {
3120+ output . appendChild ( li ) ;
31153121 }
31163122 } ) ;
31173123 } else if ( query . error === null ) {
3124+ output = document . createElement ( "div" ) ;
31183125 output . className = "search-failed" + extraClass ;
31193126 output . innerHTML = "No results :(<br/>" +
31203127 "Try on <a href=\"https://duckduckgo.com/?q=" +
@@ -4176,17 +4183,17 @@ ${item.displayPath}<span class="${type}">${name}</span>\
41764183 // up and down arrow select next/previous search result, or the
41774184 // search box if we're already at the top.
41784185 if ( e . which === 38 ) { // up
4179- const previous = document . activeElement . previousElementSibling ;
4186+ const previous = document . activeElement . parentNode . previousElementSibling ;
41804187 if ( previous ) {
4181- previous . focus ( ) ;
4188+ previous . querySelectorAll ( "a" ) . item ( 0 ) . focus ( ) ;
41824189 } else {
41834190 searchState . focus ( ) ;
41844191 }
41854192 e . preventDefault ( ) ;
41864193 } else if ( e . which === 40 ) { // down
4187- const next = document . activeElement . nextElementSibling ;
4194+ const next = document . activeElement . parentNode . nextElementSibling ;
41884195 if ( next ) {
4189- next . focus ( ) ;
4196+ next . querySelectorAll ( "a" ) . item ( 0 ) . focus ( ) ;
41904197 }
41914198 const rect = document . activeElement . getBoundingClientRect ( ) ;
41924199 if ( window . innerHeight - rect . bottom < rect . height ) {
0 commit comments