Submit the issue modal with Cmd+Return from title

Closes c4c2391d30
This commit is contained in:
Brandon Oxendine
2026-09-14 10:20:21 +02:00
committed by Rūdolfs Ošiņš
parent ba5e571337
commit e97af99286
3 changed files with 29 additions and 8 deletions
+15 -8
View File
@@ -105,6 +105,12 @@
? submitActiveVariant
: submitVariant,
);
const submitDisabled = $derived(
!isValid() ||
submitInProgress ||
disableSubmit ||
(disallowEmptyBody && body.trim() === ""),
);
let selectionStart = $state(body.length);
let selectionEnd = $state(body.length);
@@ -287,6 +293,13 @@
console.error(e);
});
}
export function triggerSubmit() {
if (submitDisabled) {
return;
}
submitFn();
}
</script>
<style>
@@ -517,10 +530,7 @@
<Button
variant={effectiveSubmitVariant}
title={emptyBodyTooltip}
disabled={!isValid() ||
submitInProgress ||
disableSubmit ||
(disallowEmptyBody && body.trim() === "")}
disabled={submitDisabled}
onclick={submitFn}>
{#if submitInProgress}
Saving…
@@ -600,10 +610,7 @@
<Button
variant={effectiveSubmitVariant}
title={emptyBodyTooltip}
disabled={!isValid() ||
submitInProgress ||
disableSubmit ||
(disallowEmptyBody && body.trim() === "")}
disabled={submitDisabled}
onclick={submitFn}>
{#if submitInProgress}
Saving…
+11
View File
@@ -4,6 +4,8 @@
import { onMount } from "svelte";
import * as utils from "@app/lib/utils";
interface Props {
autofocus?: boolean;
autoselect?: boolean;
@@ -15,6 +17,7 @@
onFocus?: () => void;
onBlur?: () => void;
onSubmit?: () => void;
onModifierSubmit?: () => void;
oninput?: FormEventHandler<HTMLInputElement>;
placeholder?: string;
type?: string;
@@ -35,6 +38,7 @@
onFocus,
onBlur,
onSubmit,
onModifierSubmit,
oninput,
placeholder,
type = "text",
@@ -65,6 +69,13 @@
function handleKeydown(event: KeyboardEvent) {
event.stopPropagation();
const auxiliarKey = utils.isMac() ? event.metaKey : event.ctrlKey;
if (auxiliarKey && event.key === "Enter" && onModifierSubmit) {
event.preventDefault();
onModifierSubmit();
return;
}
if (event.key === "Enter" && valid && onSubmit) {
onSubmit();
}
+3
View File
@@ -26,6 +26,7 @@
const { repo }: Props = $props();
let commentBox: ExtendedTextarea | undefined = $state();
let preview = $state(false);
let title = $state("");
let body = $state("");
@@ -155,10 +156,12 @@
placeholder="Title"
autofocus
onDismiss={hide}
onModifierSubmit={() => commentBox?.triggerSubmit()}
bind:value={title} />
{/if}
<ExtendedTextarea
bind:this={commentBox}
textAreaSize="fixed-height"
disableSubmit={title.trim() === ""}
disallowEmptyBody