Merge pull request #2846 from iv-org/SamantazFox-fix-search-focus-js

Ignore "/" key handling if search box is focused
pull/2851/head
Samantaz Fox 2022-01-30 23:53:34 +01:00 zatwierdzone przez GitHub
commit 2289f98c1e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 11 dodań i 1 usunięć

Wyświetl plik

@ -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 == "/") {