fix(input): handle Cmd+D when TextInput has focus

Prevents browser bookmark dialog from appearing when using
Cmd+D to toggle dictation while typing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Mohamed Boudra
2026-01-03 20:03:42 +07:00
parent fb92eb199e
commit 1f33dcb4c1

View File

@@ -351,11 +351,23 @@ export function MessageInput({
const shouldHandleDesktopSubmit = IS_WEB;
function handleDesktopSubmitKeyPress(event: WebTextInputKeyPressEvent) {
function handleDesktopKeyPress(event: WebTextInputKeyPressEvent) {
if (!shouldHandleDesktopSubmit) return;
if (event.nativeEvent.key !== "Enter") return;
const { shiftKey, metaKey, ctrlKey } = event.nativeEvent;
// Cmd+D or Ctrl+D: toggle dictation
if ((metaKey || ctrlKey) && event.nativeEvent.key === "d") {
event.preventDefault();
if (isDictating) {
cancelDictation();
} else {
startDictation();
}
return;
}
if (event.nativeEvent.key !== "Enter") return;
// Shift+Enter: add newline (default behavior, don't intercept)
if (shiftKey) return;
@@ -436,7 +448,7 @@ export function MessageInput({
onContentSizeChange={handleContentSizeChange}
editable={!isDictating && isConnected && !disabled}
onKeyPress={
shouldHandleDesktopSubmit ? handleDesktopSubmitKeyPress : undefined
shouldHandleDesktopSubmit ? handleDesktopKeyPress : undefined
}
autoFocus={IS_WEB && autoFocus}
/>