Skip to content

Commit

Permalink
Ignore search keyboard shortcuts for elements with contents that are …
Browse files Browse the repository at this point in the history
…editable (#1065)
  • Loading branch information
HiDeoo committed Nov 20, 2023
1 parent 8620bb6 commit 2d72ed6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-camels-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/starlight': patch
---

Ignore search keyboard shortcuts for elements with contents that are editable
5 changes: 3 additions & 2 deletions packages/starlight/components/Search.astro
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ const pagefindTranslations = {
// Listen for `/` and `cmd + k` keyboard shortcuts.
window.addEventListener('keydown', (e) => {
const isInput =
document.activeElement &&
['input', 'select', 'textarea'].includes(document.activeElement.tagName.toLowerCase());
document.activeElement instanceof HTMLElement &&
(['input', 'select', 'textarea'].includes(document.activeElement.tagName.toLowerCase()) ||
document.activeElement.isContentEditable);
if (e.metaKey === true && e.key === 'k') {
dialog.open ? closeModal() : openModal();
e.preventDefault();
Expand Down

0 comments on commit 2d72ed6

Please sign in to comment.