Skip to content

Commit 3a0ae52

Browse files
committed
arrownav: avoid rude event handling for form elements #887
1 parent efa0a93 commit 3a0ae52

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

static/js/theme.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,10 @@ function initArrowHorizontalNav(){
782782
var scrollEnd = 0;
783783
document.addEventListener('keydown', function(event){
784784
if( !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey ){
785+
var f = event.target.matches( formelements );
786+
if( f ){
787+
return;
788+
}
785789
if( event.which == dir_key_start ){
786790
if( !scrollStart && +el.scrollLeft.toFixed()*dir_scroll <= 0 ){
787791
prev && prev.click();
@@ -804,6 +808,10 @@ function initArrowHorizontalNav(){
804808
});
805809
document.addEventListener('keyup', function(event){
806810
if( !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey ){
811+
var f = event.target.matches( formelements );
812+
if( f ){
813+
return;
814+
}
807815
if( event.which == dir_key_start ){
808816
// check for false indication if keyup is delayed after navigation
809817
if( scrollStart == -1 ){
@@ -817,15 +825,6 @@ function initArrowHorizontalNav(){
817825
}
818826
}
819827
});
820-
821-
// avoid keyboard navigation for input fields
822-
document.querySelectorAll( formelements ).forEach( function( e ){
823-
e.addEventListener( 'keydown', function( event ){
824-
if( event.which == dir_key_start || event.which == dir_key_end ){
825-
event.stopPropagation();
826-
}
827-
});
828-
});
829828
}
830829

831830
function initMenuScrollbar(){

0 commit comments

Comments
 (0)