diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2022-06-14 15:02:31 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2022-06-14 15:14:19 +0200 |
commit | 882282d0e90f16370f435e5b3e9d36083b982e19 (patch) | |
tree | 0d4d61886d169298cdacd0ad81613bb0aaa412c1 /searx/static/themes/simple/src/js | |
parent | 7bc3d17b1196f6169b7f98008aa8ec34963ed55b (diff) | |
download | searxng-882282d0e90f16370f435e5b3e9d36083b982e19.tar.gz searxng-882282d0e90f16370f435e5b3e9d36083b982e19.zip |
[fix] keyboard.js - highlightResult: don't steal focus on click event
For keyboard navigation the highlightResult() function in keyboard.js steals the
focus. On a mouse click event (non keyboard action) the focus should resist
where it is, otherwise a marked region gets lost. This is the reason why text
can't be selected when using simple theme with JS enabled.
Closes: https://github.com/searxng/searxng/issues/794
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/static/themes/simple/src/js')
-rw-r--r-- | searx/static/themes/simple/src/js/main/keyboard.js | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/searx/static/themes/simple/src/js/main/keyboard.js b/searx/static/themes/simple/src/js/main/keyboard.js index 0eb30b09f..0c52673d9 100644 --- a/searx/static/themes/simple/src/js/main/keyboard.js +++ b/searx/static/themes/simple/src/js/main/keyboard.js @@ -34,7 +34,7 @@ searxng.ready(function () { searxng.on('.result', 'click', function (e) { if (!isElementInDetail(e.target)) { - highlightResult(this)(true); + highlightResult(this)(true, true); let resultElement = getResultElement(e.target); if (isImageResult(resultElement)) { e.preventDefault(); @@ -172,7 +172,7 @@ searxng.ready(function () { } function highlightResult (which) { - return function (noScroll) { + return function (noScroll, keepFocus) { var current = document.querySelector('.result[data-vim-selected]'), effectiveWhich = which; if (current === null) { @@ -233,9 +233,11 @@ searxng.ready(function () { if (next) { current.removeAttribute('data-vim-selected'); next.setAttribute('data-vim-selected', 'true'); - var link = next.querySelector('h3 a') || next.querySelector('a'); - if (link !== null) { - link.focus(); + if (!keepFocus) { + var link = next.querySelector('h3 a') || next.querySelector('a'); + if (link !== null) { + link.focus(); + } } if (!noScroll) { scrollPageToSelected(); |