fix: tighten GitHub submit shortcut handling (#3853)

This commit is contained in:
Jinwoo Hong
2026-05-30 12:26:04 -07:00
committed by GitHub
parent 962395e4ea
commit a5af6c2f7a
3 changed files with 14 additions and 6 deletions
@@ -66,6 +66,7 @@ import {
} from '@/components/ui/dropdown-menu'
import CommentMarkdown from '@/components/sidebar/CommentMarkdown'
import { detectLanguage } from '@/lib/language-detect'
import { isScreenSubmitShortcut } from '@/lib/screen-submit-shortcut'
import { cn } from '@/lib/utils'
import { DiffSectionItem } from '@/components/editor/DiffSectionItem'
import { useMountedRef } from '@/hooks/useMountedRef'
@@ -2749,7 +2750,7 @@ function ConversationTab({
setBodyEditing(false)
return
}
if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) {
if (isScreenSubmitShortcut(event)) {
event.preventDefault()
void handleSaveBody()
}
@@ -3173,7 +3174,7 @@ function CommentReplyForm({
onCancel()
return
}
if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
if (isScreenSubmitShortcut(e)) {
e.preventDefault()
void submit()
}
@@ -5100,7 +5101,7 @@ function GHCommentComposer({
const handleKeyDown = useCallback(
(e: React.KeyboardEvent) => {
if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
if (isScreenSubmitShortcut(e)) {
e.preventDefault()
handleSubmit()
}
@@ -68,6 +68,7 @@ import CommentMarkdown from '@/components/sidebar/CommentMarkdown'
import { detectLanguage } from '@/lib/language-detect'
import { cn } from '@/lib/utils'
import { setWithLRU } from '@/lib/scroll-cache'
import { isScreenSubmitShortcut } from '@/lib/screen-submit-shortcut'
import { DiffSectionItem } from '@/components/editor/DiffSectionItem'
import { useMountedRef } from '@/hooks/useMountedRef'
import type { DecoratedDiffComment } from '@/components/diff-comments/useDiffCommentDecorator'
@@ -2878,7 +2879,7 @@ function ConversationTab({
setBodyEditing(false)
return
}
if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) {
if (isScreenSubmitShortcut(event)) {
event.preventDefault()
void handleSaveBody()
}
@@ -3302,7 +3303,7 @@ function CommentReplyForm({
onCancel()
return
}
if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
if (isScreenSubmitShortcut(e)) {
e.preventDefault()
void submit()
}
@@ -4995,7 +4996,7 @@ function GHCommentComposer({
const handleKeyDown = useCallback(
(e: React.KeyboardEvent) => {
if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
if (isScreenSubmitShortcut(e)) {
e.preventDefault()
handleSubmit()
}
@@ -40,6 +40,12 @@ describe('screen submit shortcut', () => {
expect(isScreenSubmitShortcut({ key: 'Escape', ctrlKey: true })).toBe(false)
})
it('ignores Windows Ctrl+Alt+Enter chords', () => {
setUserAgent('Windows NT')
expect(isScreenSubmitShortcut({ key: 'Enter', ctrlKey: true, altKey: true })).toBe(false)
})
it('ignores composing Enter events', () => {
setUserAgent('Linux')