Fix: disable the search keyboard shortcut in a form (#2041)

This commit is contained in:
ZhenShuo Leo committed 2025-05-06 17:32:04 +08:00
1 parent 1d21656d5e
commit e169dfa5ec
1 file changed
+8 -1
+8 -1
View File
@@ -25,7 +25,14 @@ modal.addEventListener("click", function (event) {
document.addEventListener("keydown", function (event) {
// Forward slash to open search wrapper
if (event.key == "/") {
if (!searchVisible) {
const active = document.activeElement
const tag = active.tagName
const isInputField =
tag === "INPUT" ||
tag === "TEXTAREA" ||
active.isContentEditable
if (!searchVisible && !isInputField) {
event.preventDefault();
displaySearch();
}