diff --git a/www/index.html b/www/index.html index 5e4157a9..501340be 100644 --- a/www/index.html +++ b/www/index.html @@ -248,7 +248,7 @@ + class="form-control" style="z-index: 0; width: 99.5%" autocomplete="off" /> diff --git a/www/js/app.js b/www/js/app.js index 1d83cc1f..60bbe7ba 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -264,6 +264,10 @@ prefix.addEventListener('keydown', function (e) { // User pressed Down arrow, Up arrow, Left arrow, Right arrow, or Enter // This is needed to prevent processing in the keyup event : https://stackoverflow.com/questions/9951274 keyPressHandled = true; + if (/Enter/.test(e.key)) { + // Don't refresh the page if Enter is pressed even before any search results are selected + e.preventDefault(); + } var activeElement = document.querySelector('#articleList .hover') || document.querySelector('#articleList a'); if (!activeElement) return; // If user presses Enter or Right arrow, read the dirEntry or open snippet @@ -276,6 +280,7 @@ prefix.addEventListener('keydown', function (e) { // Open the snippet container uiUtil.toggleSnippet(activeElement); } + // Allow left/right arrow keys to move around in search text box when not opening snippet return; } e.preventDefault(); @@ -5087,8 +5092,12 @@ function populateListOfArticles (dirEntryArray, reportingSearch) { if (dirEntry.snippet) { dirEntryTitle = '' + dirEntryTitle + ''; } + let classAttribute = 'list-group-item'; + if (i === 0) { + classAttribute += ' hover'; + } articleListDivHtml += '' + (reportingSearch.searchUrlIndex ? dirEntry.namespace + '/' + dirEntry.url : '' + dirEntryTitle) + ''; + '" class="' + classAttribute + '" role="option">' + (reportingSearch.searchUrlIndex ? dirEntry.namespace + '/' + dirEntry.url : '' + dirEntryTitle) + ''; } // Set the innerHTML once