compose and add-account are real forms, so enter submits them

Compose's To/Cc/Bcc/Subject fields, and each of the three add-account
forms, sat in a plain div — enter did nothing and the button was the
only way in. Wrapped each in a <form onSubmit>, marked every button
that isn't the submit action type="button" (attach, cancel, cc/bcc
toggles, the recipient-suggestion picks), so none of them accidentally
submit now that a form exists around them. The compose body stays a
contenteditable div, which never triggers native enter-to-submit, so
Cmd/Ctrl+Enter wasn't needed to keep newlines working.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-19 10:45:21 +00:00
co-authored by Claude Opus 5
parent bc9934fc55
commit 3db9534614
2 changed files with 143 additions and 113 deletions
+22 -13
View File
@@ -85,7 +85,8 @@ export const EmailAccounts = () => {
}
};
const handleGmailOAuth = async () => {
const handleGmailOAuth = async (ev?: React.FormEvent) => {
ev?.preventDefault();
setSaving(true);
try {
const status = await client.get<{ connected: boolean; email: string | null }>('/integrations/google/status');
@@ -116,7 +117,8 @@ export const EmailAccounts = () => {
}
};
const handlePasswordSubmit = async () => {
const handlePasswordSubmit = async (ev?: React.FormEvent) => {
ev?.preventDefault();
if (!form.email.trim() || !form.password.trim()) return;
setSaving(true);
try {
@@ -304,7 +306,10 @@ export const EmailAccounts = () => {
{/* Gmail OAuth form */}
{activeForm === 'gmail-oauth' && (
<div className="grid gap-3 rounded-lg border border-duck-dark/10 dark:border-foreground/10 p-4">
<form
onSubmit={handleGmailOAuth}
className="grid gap-3 rounded-lg border border-duck-dark/10 dark:border-foreground/10 p-4"
>
<p className="text-sm font-medium text-duck-dark dark:text-foreground">Add Gmail (OAuth)</p>
<input
type="text"
@@ -317,16 +322,19 @@ export const EmailAccounts = () => {
<Button type="button" variant="ghost" onClick={resetForm} className="h-9 cursor-pointer">
Cancel
</Button>
<Button type="button" onClick={handleGmailOAuth} disabled={saving} className="h-9 flex-1 cursor-pointer">
<Button type="submit" disabled={saving} className="h-9 flex-1 cursor-pointer">
{saving ? <Loader2 className="h-4 w-4 animate-spin" /> : 'Connect & Add'}
</Button>
</div>
</div>
</form>
)}
{/* Gmail App Password form */}
{activeForm === 'gmail-password' && (
<div className="grid gap-3 rounded-lg border border-duck-dark/10 dark:border-foreground/10 p-4">
<form
onSubmit={handlePasswordSubmit}
className="grid gap-3 rounded-lg border border-duck-dark/10 dark:border-foreground/10 p-4"
>
<p className="text-sm font-medium text-duck-dark dark:text-foreground">Add Gmail (App Password)</p>
<div className="text-xs text-duck-dark/50 dark:text-foreground/50 grid gap-1.5">
<p>To create an App Password:</p>
@@ -373,20 +381,22 @@ export const EmailAccounts = () => {
Cancel
</Button>
<Button
type="button"
onClick={handlePasswordSubmit}
type="submit"
disabled={!form.email.trim() || !form.password.trim() || saving}
className="h-9 flex-1 cursor-pointer"
>
{saving ? <Loader2 className="h-4 w-4 animate-spin" /> : 'Test & Save'}
</Button>
</div>
</div>
</form>
)}
{/* Generic IMAP form */}
{activeForm === 'imap' && (
<div className="grid gap-3 rounded-lg border border-duck-dark/10 dark:border-foreground/10 p-4">
<form
onSubmit={handlePasswordSubmit}
className="grid gap-3 rounded-lg border border-duck-dark/10 dark:border-foreground/10 p-4"
>
<p className="text-sm font-medium text-duck-dark dark:text-foreground">Add IMAP Account</p>
<input
type="email"
@@ -439,15 +449,14 @@ export const EmailAccounts = () => {
Cancel
</Button>
<Button
type="button"
onClick={handlePasswordSubmit}
type="submit"
disabled={!form.email.trim() || !form.password.trim() || !form.imapHost.trim() || saving}
className="h-9 flex-1 cursor-pointer"
>
{saving ? <Loader2 className="h-4 w-4 animate-spin" /> : 'Test & Save'}
</Button>
</div>
</div>
</form>
)}
{/* Add account button */}