diff --git a/web_src/js/components/RepoFileSearch.vue b/web_src/js/components/RepoFileSearch.vue
index 4728d0aef2..650b012113 100644
--- a/web_src/js/components/RepoFileSearch.vue
+++ b/web_src/js/components/RepoFileSearch.vue
@@ -154,7 +154,7 @@ watch([searchQuery, filteredFiles], async () => {
@input="handleSearchInput" @keydown="handleKeyDown"
@focus="isInputFocused = true" @blur="isInputFocused = false"
>
- T
+ T
@@ -202,7 +202,7 @@ watch([searchQuery, filteredFiles], async () => {
border-color: var(--color-primary) !important;
}
-.repo-search-shortcut-hint {
+.repo-file-search-shortcut-hint {
position: absolute;
right: 10px;
top: 50%;
@@ -219,7 +219,7 @@ watch([searchQuery, filteredFiles], async () => {
}
/* Hide kbd when input is focused so it doesn't interfere with focus border */
-.repo-file-search-input-wrapper input:focus + .repo-search-shortcut-hint {
+.repo-file-search-input-wrapper input:focus + .repo-file-search-shortcut-hint {
display: none;
}
diff --git a/web_src/js/modules/observer.ts b/web_src/js/modules/observer.ts
index 45db1360af..f1d5d65613 100644
--- a/web_src/js/modules/observer.ts
+++ b/web_src/js/modules/observer.ts
@@ -69,9 +69,9 @@ function attachGlobalEvents() {
// Elements declare their keyboard shortcuts via data-global-keyboard-shortcut attribute.
// When a matching key is pressed, the element is focused (for inputs) or clicked (for buttons/links).
document.addEventListener('keydown', (e: KeyboardEvent) => {
- // Don't trigger shortcuts when typing in input fields
+ // Don't trigger shortcuts when typing in input fields or contenteditable areas
const target = e.target as HTMLElement;
- if (target.matches('input, textarea, select, [contenteditable="true"]')) {
+ if (target.matches('input, textarea, select') || target.isContentEditable) {
return;
}
@@ -82,7 +82,8 @@ function attachGlobalEvents() {
// Find element with matching shortcut (case-insensitive)
const key = e.key.toLowerCase();
- const elem = document.querySelector(`[data-global-keyboard-shortcut="${key}"]`);
+ const escapedKey = CSS.escape(key);
+ const elem = document.querySelector(`[data-global-keyboard-shortcut="${escapedKey}"]`);
if (!elem) return;
e.preventDefault();