Skip to content

Commit b96f2b7

Browse files
committed
fix: Shift+G keybind prevented typing capital G in input box
1 parent eb3ba4f commit b96f2b7

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/components/AIView.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ChatProvider } from "@/contexts/ChatContext";
1313
import { ThinkingProvider } from "@/contexts/ThinkingContext";
1414
import { ModeProvider } from "@/contexts/ModeContext";
1515
import type { WorkspaceChatMessage } from "@/types/ipc";
16-
import { matchesKeybind, formatKeybind, KEYBINDS } from "@/utils/ui/keybinds";
16+
import { matchesKeybind, formatKeybind, KEYBINDS, isEditableElement } from "@/utils/ui/keybinds";
1717
import {
1818
isCaughtUpMessage,
1919
isStreamError,
@@ -423,6 +423,11 @@ const AIViewInner: React.FC<AIViewProps> = ({ workspaceId, projectName, branch,
423423
// Handle keyboard shortcuts
424424
useEffect(() => {
425425
const handleKeyDown = (e: KeyboardEvent) => {
426+
// Don't handle shortcuts if user is typing in an input field
427+
if (isEditableElement(e.target)) {
428+
return;
429+
}
430+
426431
if (matchesKeybind(e, KEYBINDS.JUMP_TO_BOTTOM)) {
427432
e.preventDefault();
428433
jumpToBottom();

src/utils/ui/keybinds.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ export function matchesKeybind(
5656
return true;
5757
}
5858

59+
/**
60+
* Check if the event target is an editable element (input, textarea, contentEditable).
61+
* Used to prevent global keyboard shortcuts from interfering with text input.
62+
*/
63+
export function isEditableElement(target: EventTarget | null): boolean {
64+
if (!target || !(target instanceof HTMLElement)) {
65+
return false;
66+
}
67+
68+
const tagName = target.tagName.toLowerCase();
69+
return tagName === "input" || tagName === "textarea" || target.contentEditable === "true";
70+
}
71+
5972
/**
6073
* Format a keybind for display to users.
6174
* Returns Mac-style symbols on macOS, or Windows-style text elsewhere.

0 commit comments

Comments
 (0)