Skip to content

Commit

Permalink
[fix] keyboard navigation / simple theme (UI)
Browse files Browse the repository at this point in the history
- avoid loop select
- fix select next item in mixed result lists

Replaces: searxng#2789
Closes: searxng#2751
Closes: searxng#2788
  • Loading branch information
BernieHuang2008 authored and return42 committed Sep 16, 2023
1 parent ec540a9 commit d6f7033
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
3 changes: 2 additions & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,5 @@ features or generally made searx better:
- Milad Laly @Milad-Laly
- @llmII
- @blob42 `<https://blob42.xyz>`_
- Paolo Basso `<https://github.com/paolobasso99>`
- Paolo Basso `<https://github.com/paolobasso99>`
- Bernie Huang `<https://github.com/BernieHuang2008>`
11 changes: 3 additions & 8 deletions searx/static/themes/simple/src/js/main/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ searxng.ready(function () {
}

var next, results = document.querySelectorAll('.result');
results = Array.from(results); // convert NodeList to Array for further use

if (typeof effectiveWhich !== 'string') {
next = effectiveWhich;
Expand All @@ -233,16 +234,10 @@ searxng.ready(function () {
}
break;
case 'down':
next = current.nextElementSibling;
if (next === null) {
next = results[0];
}
next = results[results.indexOf(current) + 1] || current;
break;
case 'up':
next = current.previousElementSibling;
if (next === null) {
next = results[results.length - 1];
}
next = results[results.indexOf(current) - 1] || current;
break;
case 'bottom':
next = results[results.length - 1];
Expand Down

0 comments on commit d6f7033

Please sign in to comment.