diff --git a/web_server_files/static/js/search_vulns.js b/web_server_files/static/js/search_vulns.js index e0e7476..2188472 100644 --- a/web_server_files/static/js/search_vulns.js +++ b/web_server_files/static/js/search_vulns.js @@ -1114,9 +1114,11 @@ function moveCPESuggestionUpDown(event) { else if (event.keyCode == 40) curSelectedCPESuggestion++; - // enforce lower and upper bounds - curSelectedCPESuggestion = Math.max(-1, curSelectedCPESuggestion); - curSelectedCPESuggestion = Math.min(curSelectedCPESuggestion, $("#cpeSuggestions").find('ul').children('li').length - 1); + // wrap around if moving below available suggestions or above them + if (curSelectedCPESuggestion < 0) + curSelectedCPESuggestion = $("#cpeSuggestions").find('ul').children('li').length - 1; + else if (curSelectedCPESuggestion > $("#cpeSuggestions").find('ul').children('li').length - 1) + curSelectedCPESuggestion = 0; if (curSelectedCPESuggestion > -1) { const suggestionElement = $('#cpe-suggestion-' + curSelectedCPESuggestion);