Skip to content

Commit 52678db

Browse files
committed
Don’t process keyboard shortcut if input is focused
Fixes #7150
1 parent 6f7e520 commit 52678db

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

news/changelog-1.4.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
## Website Search
115115

116116
- ([#7105](https://github.com/quarto-dev/quarto-cli/issues/7105)): Improve search results by raising default limit and fixing and removing warning that would appear for Algolia when limit was more than 20.
117+
- ([#7150](https://github.com/quarto-dev/quarto-cli/issues/7150)): Search keyboard shortcut will not intercept keys directed at inputs.
117118

118119
## Books
119120

src/resources/projects/website/search/quarto-search.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,19 @@ window.document.addEventListener("DOMContentLoaded", function (_event) {
380380
document.addEventListener("keyup", (event) => {
381381
const { key } = event;
382382
const kbds = quartoSearchOptions["keyboard-shortcut"];
383-
if (kbds && kbds.includes(key)) {
383+
const focusedEl = document.activeElement;
384+
385+
const isFormElFocused = [
386+
"input",
387+
"select",
388+
"textarea",
389+
"button",
390+
"option",
391+
].find((tag) => {
392+
return focusedEl.tagName.toLowerCase() === tag;
393+
});
394+
395+
if (kbds && kbds.includes(key) && !isFormElFocused) {
384396
event.preventDefault();
385397
window.quartoOpenSearch();
386398
}

0 commit comments

Comments
 (0)