Skip to content

Commit bd89403

Browse files
committed
fix hotkey issue
1 parent 56932ab commit bd89403

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

website/themes/book/assets/search.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
return;
2525
}
2626

27+
// Don't hijack typing in other editable fields (e.g. the Gitalk comment box).
28+
// Otherwise a search hotkey ("s" / "/") typed there steals focus to the search
29+
// box, making it lose focus after every keystroke.
30+
const active = document.activeElement;
31+
if (active && (active.tagName === 'INPUT' || active.tagName === 'TEXTAREA' || active.tagName === 'SELECT' || active.isContentEditable)) {
32+
return;
33+
}
34+
2735
const characterPressed = String.fromCharCode(event.charCode);
2836
if (!isHotkey(characterPressed)) {
2937
return;

0 commit comments

Comments
 (0)