mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Merge pull request #2846 from iv-org/SamantazFox-fix-search-focus-js
Ignore "/" key handling if search box is focused
This commit is contained in:
commit
2289f98c1e
1 changed files with 11 additions and 1 deletions
|
@ -146,7 +146,17 @@
|
||||||
// Handle keypresses
|
// Handle keypresses
|
||||||
window.addEventListener('keydown', (event) => {
|
window.addEventListener('keydown', (event) => {
|
||||||
// Ignore modifier keys
|
// 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 '/'
|
// Focus search bar on '/'
|
||||||
if (event.key == "/") {
|
if (event.key == "/") {
|
||||||
|
|
Loading…
Reference in a new issue