From 3a0ae52e610bbf99e6a4182a1d7889954e9b7d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Thu, 22 Aug 2024 19:25:40 +0200 Subject: [PATCH] arrownav: avoid rude event handling for form elements #887 --- static/js/theme.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/static/js/theme.js b/static/js/theme.js index 32657a4553..9535906d8d 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -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(){