From 3bac832eb09f7c279a93420440f394af0f5cd00e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Fri, 18 Nov 2022 21:09:50 +0100 Subject: [PATCH] search: only redirect keyboard events initially to menu #386 otherwise we are not able to tab thru search results on the search page --- static/js/theme.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/static/js/theme.js b/static/js/theme.js index cc8730fd68..946022ad2a 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -393,7 +393,7 @@ function initMenuScrollbar(){ var elm = document.querySelector('#content-wrapper'); var elt = document.querySelector('#TableOfContents'); - var autofocus = false; + var autofocus = true; document.addEventListener('keydown', function(event){ // for initial keyboard scrolling support, no element // may be hovered, but we still want to react on @@ -402,6 +402,13 @@ function initMenuScrollbar(){ // it and give focus to the scrollbar - only // to just remove the focus right after scrolling // happend + autofocus = false; + if( event.shiftKey || event.altKey || event.ctrlKey || event.metaKey || event.which < 32 || event.which > 40 ){ + // if tab key was pressed, we are ended with our initial + // focus job + return; + } + var c = elc && elc.matches(':hover'); var m = elm && elm.matches(':hover'); var t = elt && elt.matches(':hover'); @@ -409,7 +416,6 @@ function initMenuScrollbar(){ if( !c && !m && !t && !f ){ // only do this hack if none of our scrollbars // is hovered - autofocus = true; // if we are showing the sidebar as a flyout we // want to scroll the content-wrapper, otherwise we want // to scroll the body