Skip to content
TypeScript

fix(web): save PR body edits with Cmd/Ctrl+Enter (#10660)

oliver60eff99f25db
diff --git a/apps/web/src/components/pullRequest/PullRequestMarkdownEditor.tsx b/apps/web/src/components/pullRequest/PullRequestMarkdownEditor.tsx
index fde29d02377..a92418bbb86 100644
--- a/apps/web/src/components/pullRequest/PullRequestMarkdownEditor.tsx
+++ b/apps/web/src/components/pullRequest/PullRequestMarkdownEditor.tsx
@@ -55,11 +55,24 @@ export function PullRequestMarkdownEditor({
setDraft(value);
}
const empty = draft.trim().length === 0;
+ const saveDisabled = saving || (empty && !allowEmpty);
return (
<div
className={cn("space-y-2", className)}
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 (!saveDisabled && !event.repeat) onSave(draft);
+ return;
+ }
if (event.key !== "Escape" || saving) return;
event.preventDefault();
onCancel();
@@ -106,12 +119,7 @@ export function PullRequestMarkdownEditor({
<Button size="xs" variant="ghost" disabled={saving} onClick={onCancel}>
Cancel
</Button>
- <Button
- size="xs"
- variant="outline"
- disabled={saving || (empty && !allowEmpty)}
- onClick={() => onSave(draft)}
- >
+ <Button size="xs" variant="outline" disabled={saveDisabled} onClick={() => onSave(draft)}>
{saving ? "Saving..." : "Save"}
</Button>
</div>