Skip to content

Commit

Permalink
arrownav: avoid rude event handling for form elements #887
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Aug 22, 2024
1 parent efa0a93 commit 3a0ae52
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions static/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 ){
Expand All @@ -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(){
Expand Down

0 comments on commit 3a0ae52

Please sign in to comment.