mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
search: only redirect keyboard events initially to menu #386
otherwise we are not able to tab thru search results on the search page
This commit is contained in:
parent
14a7988db3
commit
3bac832eb0
1 changed files with 8 additions and 2 deletions
|
@ -393,7 +393,7 @@ function initMenuScrollbar(){
|
||||||
var elm = document.querySelector('#content-wrapper');
|
var elm = document.querySelector('#content-wrapper');
|
||||||
var elt = document.querySelector('#TableOfContents');
|
var elt = document.querySelector('#TableOfContents');
|
||||||
|
|
||||||
var autofocus = false;
|
var autofocus = true;
|
||||||
document.addEventListener('keydown', function(event){
|
document.addEventListener('keydown', function(event){
|
||||||
// for initial keyboard scrolling support, no element
|
// for initial keyboard scrolling support, no element
|
||||||
// may be hovered, but we still want to react on
|
// may be hovered, but we still want to react on
|
||||||
|
@ -402,6 +402,13 @@ function initMenuScrollbar(){
|
||||||
// it and give focus to the scrollbar - only
|
// it and give focus to the scrollbar - only
|
||||||
// to just remove the focus right after scrolling
|
// to just remove the focus right after scrolling
|
||||||
// happend
|
// 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 c = elc && elc.matches(':hover');
|
||||||
var m = elm && elm.matches(':hover');
|
var m = elm && elm.matches(':hover');
|
||||||
var t = elt && elt.matches(':hover');
|
var t = elt && elt.matches(':hover');
|
||||||
|
@ -409,7 +416,6 @@ function initMenuScrollbar(){
|
||||||
if( !c && !m && !t && !f ){
|
if( !c && !m && !t && !f ){
|
||||||
// only do this hack if none of our scrollbars
|
// only do this hack if none of our scrollbars
|
||||||
// is hovered
|
// is hovered
|
||||||
autofocus = true;
|
|
||||||
// if we are showing the sidebar as a flyout we
|
// if we are showing the sidebar as a flyout we
|
||||||
// want to scroll the content-wrapper, otherwise we want
|
// want to scroll the content-wrapper, otherwise we want
|
||||||
// to scroll the body
|
// to scroll the body
|
||||||
|
|
Loading…
Reference in a new issue