Skip to content

Commit

Permalink
Ignore "/" key handling if search box is focused
Browse files Browse the repository at this point in the history
Fixes a side effect of iv-org#2814
See: iv-org#2791 (comment)
  • Loading branch information
SamantazFox authored and sriegler committed Nov 14, 2023
1 parent 56775ee commit 3f44e6c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion assets/js/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,17 @@
// Handle keypresses
window.addEventListener('keydown', (event) => {
// Ignore modifier keys
if (event.ctrlKey || event.metaKey) { return; }
if (event.ctrlKey || event.metaKey) return;

// Ignore shortcuts if any text input is focused
let focused_tag = document.activeElement.tagName.toLowerCase();
let focused_type = document.activeElement.type.toLowerCase();
let allowed = /^(button|checkbox|file|radio|submit)$/;

if (focused_tag === "textarea" ||
(focused_tag === "input" && !focused_type.match(allowed))
)
return;

// Focus search bar on '/'
if (event.key == "/") {
Expand Down

0 comments on commit 3f44e6c

Please sign in to comment.