arrownav: avoid rude event handling for form elements #887

This commit is contained in:
Sören Weber 2024-08-22 19:25:40 +02:00
parent efa0a93fb7
commit 3a0ae52e61
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -782,6 +782,10 @@ function initArrowHorizontalNav(){
var scrollEnd = 0;
document.addEventListener('keydown', function(event){
if( !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey ){
var f = event.target.matches( formelements );
if( f ){
return;
}
if( event.which == dir_key_start ){
if( !scrollStart && +el.scrollLeft.toFixed()*dir_scroll <= 0 ){
prev && prev.click();
@ -804,6 +808,10 @@ function initArrowHorizontalNav(){
});
document.addEventListener('keyup', function(event){
if( !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey ){
var f = event.target.matches( formelements );
if( f ){
return;
}
if( event.which == dir_key_start ){
// check for false indication if keyup is delayed after navigation
if( scrollStart == -1 ){
@ -817,15 +825,6 @@ function initArrowHorizontalNav(){
}
}
});
// avoid keyboard navigation for input fields
document.querySelectorAll( formelements ).forEach( function( e ){
e.addEventListener( 'keydown', function( event ){
if( event.which == dir_key_start || event.which == dir_key_end ){
event.stopPropagation();
}
});
});
}
function initMenuScrollbar(){