summaryrefslogtreecommitdiffstats
path: root/assets
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2022-01-28 18:19:32 +0100
committerSamantaz Fox <coding@samantaz.fr>2022-01-30 23:27:42 +0100
commit15c66e2b01cadc616b1db64a74928209dee46873 (patch)
tree6d9e1ab957c46c28584df882e62540ed82696404 /assets
parenteba311baa94e8d2848beaad5310b05d5ec22d35c (diff)
downloadinvidious-15c66e2b01cadc616b1db64a74928209dee46873.tar.gz
invidious-15c66e2b01cadc616b1db64a74928209dee46873.tar.bz2
invidious-15c66e2b01cadc616b1db64a74928209dee46873.zip
Ignore "/" key handling if search box is focused
Fixes a side effect of https://github.com/iv-org/invidious/pull/2814 See: https://github.com/iv-org/invidious/issues/2791#issuecomment-1018264144
Diffstat (limited to 'assets')
-rw-r--r--assets/js/handlers.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/assets/js/handlers.js b/assets/js/handlers.js
index a417fcca..d3957b89 100644
--- a/assets/js/handlers.js
+++ b/assets/js/handlers.js
@@ -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 == "/") {