Skip to content

Commit b344e1a

Browse files
committed
handlers.js: fix TypeError on document.activeElement.type
1 parent 3c882cf commit b344e1a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

assets/js/handlers.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@
150150

151151
// Ignore shortcuts if any text input is focused
152152
let focused_tag = document.activeElement.tagName.toLowerCase();
153-
let focused_type = document.activeElement.type.toLowerCase();
154-
let allowed = /^(button|checkbox|file|radio|submit)$/;
153+
const allowed = /^(button|checkbox|file|radio|submit)$/;
155154

156-
if (focused_tag === "textarea" ||
157-
(focused_tag === "input" && !focused_type.match(allowed))
158-
)
159-
return;
155+
if (focused_tag === "textarea") return;
156+
if (focused_tag === "input") {
157+
let focused_type = document.activeElement.type.toLowerCase();
158+
if (!focused_type.match(allowed)) return;
159+
}
160160

161161
// Focus search bar on '/'
162162
if (event.key == "/") {

0 commit comments

Comments
 (0)