search: don't let scrollbar hijack input event of search term#210

This commit is contained in:
Sören Weber 2022-03-06 11:45:33 +01:00
parent 5f76f6ce27
commit 6ad4f1c4fd
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589

View file

@ -5,6 +5,8 @@ if( !isIE ){
}
var touchsupport = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)
var formelements = 'button, datalist, fieldset, input, label, legend, meter, optgroup, option, output, progress, select, textarea';
function switchTab(tabGroup, tabId) {
allTabItems = jQuery("[data-tab-group='"+tabGroup+"']");
targetTabItems = jQuery("[data-tab-group='"+tabGroup+"'][data-tab-item='"+tabId+"']");
@ -178,7 +180,7 @@ function initArrowNav(){
});
// avoid keyboard navigation for input fields
jQuery('input, textarea').keydown(function (e) {
jQuery(formelements).keydown(function (e) {
if (e.which == '37' || e.which == '39') {
e.stopPropagation();
}
@ -193,7 +195,7 @@ function initMenuScrollbar(){
content = '#body';
}
var autofocus = false;
document.addEventListener('keydown', function(){
document.addEventListener('keydown', function(event){
// for initial keyboard scrolling support, no element
// may be hovered, but we still want to react on
// cursor/page up/down. because we can't hack
@ -203,7 +205,8 @@ function initMenuScrollbar(){
// happend
var p = document.querySelector(content).matches(':hover');
var m = document.querySelector('#content-wrapper').matches(':hover');
if( !p && !m ){
var f = event.target.matches( formelements );
if( !p && !m && !f ){
// only do this hack if none of our scrollbars
// is hovered
autofocus = true;