Skip to content

Commit c636224

Browse files
committed
Fix enter key in search results
1 parent 6a333b2 commit c636224

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

www/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ <h3 style="margin-top:10px;">
248248
<a class="btn btn-primary" style="display:none;" title="Forward" id="btnForwardAlt"><span class="glyphicon glyphicon-circle-arrow-right"></span></a>
249249
</span>
250250
<input type="search" id="prefix" placeholder="Search [.*] or space key..."
251-
class="form-control" style="z-index: 0; width: 99.5%" />
251+
class="form-control" style="z-index: 0; width: 99.5%" autocomplete="off" />
252252
<span class="input-group-btn">
253253
<a class="btn btn-primary" title="Article Search" id="searchArticles" style="display:none;"><span class="glyphicon glyphicon-book"></span></a>
254254
<a class="btn btn-primary" title="Ctrl-Shift-F or Alt-F: Find and highlight text in article..." id="findText"><span class="glyphicon glyphicon-search"></span></a>

www/js/app.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ prefix.addEventListener('keydown', function (e) {
264264
// User pressed Down arrow, Up arrow, Left arrow, Right arrow, or Enter
265265
// This is needed to prevent processing in the keyup event : https://stackoverflow.com/questions/9951274
266266
keyPressHandled = true;
267+
if (/Enter/.test(e.key)) {
268+
// Don't refresh the page if Enter is pressed even before any search results are selected
269+
e.preventDefault();
270+
}
267271
var activeElement = document.querySelector('#articleList .hover') || document.querySelector('#articleList a');
268272
if (!activeElement) return;
269273
// If user presses Enter or Right arrow, read the dirEntry or open snippet
@@ -276,6 +280,7 @@ prefix.addEventListener('keydown', function (e) {
276280
// Open the snippet container
277281
uiUtil.toggleSnippet(activeElement);
278282
}
283+
// Allow left/right arrow keys to move around in search text box when not opening snippet
279284
return;
280285
}
281286
e.preventDefault();
@@ -5087,8 +5092,12 @@ function populateListOfArticles (dirEntryArray, reportingSearch) {
50875092
if (dirEntry.snippet) {
50885093
dirEntryTitle = '<strong>' + dirEntryTitle + '</strong>';
50895094
}
5095+
let classAttribute = 'list-group-item';
5096+
if (i === 0) {
5097+
classAttribute += ' hover';
5098+
}
50905099
articleListDivHtml += '<a href="#" dirEntryId="' + dirEntryStringId +
5091-
'" class="list-group-item" role="option">' + (reportingSearch.searchUrlIndex ? dirEntry.namespace + '/' + dirEntry.url : '' + dirEntryTitle) + '</a>';
5100+
'" class="' + classAttribute + '" role="option">' + (reportingSearch.searchUrlIndex ? dirEntry.namespace + '/' + dirEntry.url : '' + dirEntryTitle) + '</a>';
50925101
}
50935102

50945103
// Set the innerHTML once

0 commit comments

Comments
 (0)