summaryrefslogtreecommitdiffstats
path: root/assets/js
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2022-01-30 23:53:34 +0100
committerGitHub <noreply@github.com>2022-01-30 23:53:34 +0100
commit2289f98c1ee5d32aba37f4d46f5a8a6cb2a52641 (patch)
treea5e7e0f47f78467debf74163247b8f4489d2c6c9 /assets/js
parent49edf0ee330542582506cf1b198641fa5ed3f58e (diff)
parent15c66e2b01cadc616b1db64a74928209dee46873 (diff)
downloadinvidious-2289f98c1ee5d32aba37f4d46f5a8a6cb2a52641.tar.gz
invidious-2289f98c1ee5d32aba37f4d46f5a8a6cb2a52641.tar.bz2
invidious-2289f98c1ee5d32aba37f4d46f5a8a6cb2a52641.zip
Merge pull request #2846 from iv-org/SamantazFox-fix-search-focus-js
Ignore "/" key handling if search box is focused
Diffstat (limited to 'assets/js')
-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 == "/") {