Skip to content
TypeScript

fix(web): submit PR comments with Cmd/Ctrl+Enter (#11994)

oliverf45c6b4a7559
diff --git a/apps/web/src/components/pullRequest/PullRequestCommentComposer.tsx b/apps/web/src/components/pullRequest/PullRequestCommentComposer.tsx
index 7d749f0f3fe..9eef7cdb2e2 100644
--- a/apps/web/src/components/pullRequest/PullRequestCommentComposer.tsx
+++ b/apps/web/src/components/pullRequest/PullRequestCommentComposer.tsx
@@ -123,6 +123,19 @@ export function PullRequestCommentComposer({
placeholder="Leave a comment"
aria-label="Comment on this pull request"
onChange={(event) => setBody(event.target.value)}
+ onKeyDown={(event) => {
+ if (event.nativeEvent.isComposing || event.keyCode === 229) return;
+ if (
+ event.key === "Enter" &&
+ (event.metaKey || event.ctrlKey) &&
+ !event.shiftKey &&
+ !event.altKey
+ ) {
+ event.preventDefault();
+ event.stopPropagation();
+ if (!event.repeat) void submit("comment");
+ }
+ }}
/>
<div className="flex flex-wrap justify-end gap-2">
{followUpAction === null ? null : (