wrap the document, record and send-mail editors in real forms

typing into a field and pressing enter did nothing in the document editor, the
customer/item/payment/expense dialogs and the send-document dialog — inputs sat
in a div, so the button was the only way to submit. now each wraps in a
<form onSubmit>, with every non-submit button (cancel, close, add/remove line,
"same as billing") marked type="button" so it doesn't submit instead of doing
its own thing.

the record editors share one dialog shell (EditorShell), so a single form
there covers customer, item, payment and expense at once — kept the dialog's
grid gap intact with display:contents rather than nesting a box.

left the list-view filter boxes and the reports date-range picker alone: none
of them has a submit action, so there's nothing for enter to do.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-19 10:43:59 +00:00
co-authored by Claude Opus 5
parent 464acee34e
commit 06203f97b3
3 changed files with 85 additions and 65 deletions
+24 -14
View File
@@ -87,21 +87,31 @@ const EditorShell = ({
}) => (
<Dialog open onOpenChange={(open) => !open && onClose()}>
<DialogContent className={wide ? 'sm:max-w-2xl' : 'sm:max-w-lg'}>
<DialogHeader>
<DialogTitle>{title}</DialogTitle>
{description && <DialogDescription>{description}</DialogDescription>}
</DialogHeader>
{/* `contents` keeps the form invisible to DialogContent's grid layout — it still owns the gap between
header, body and footer, the form just carries Enter-to-submit across all three. */}
<form
onSubmit={(ev) => {
ev.preventDefault();
onSave();
}}
className="contents"
>
<DialogHeader>
<DialogTitle>{title}</DialogTitle>
{description && <DialogDescription>{description}</DialogDescription>}
</DialogHeader>
<div className="max-h-[65vh] space-y-3 overflow-y-auto pr-1">{children}</div>
<div className="max-h-[65vh] space-y-3 overflow-y-auto pr-1">{children}</div>
<DialogFooter>
<Button variant="ghost" size="sm" onClick={onClose} disabled={busy}>
Cancel
</Button>
<Button size="sm" onClick={onSave} disabled={!canSave || busy}>
{busy ? 'Saving…' : 'Save'}
</Button>
</DialogFooter>
<DialogFooter>
<Button variant="ghost" size="sm" type="button" onClick={onClose} disabled={busy}>
Cancel
</Button>
<Button type="submit" size="sm" disabled={!canSave || busy}>
{busy ? 'Saving…' : 'Save'}
</Button>
</DialogFooter>
</form>
</DialogContent>
</Dialog>
);
@@ -289,7 +299,7 @@ const AddressFields = ({
<div className="mb-2 flex items-center justify-between">
<div className="text-[10px] font-medium uppercase tracking-wide text-muted-foreground">{label}</div>
{onCopy && (
<Button variant="ghost" size="sm" className="h-6 text-[10px]" onClick={onCopy}>
<Button variant="ghost" size="sm" type="button" className="h-6 text-[10px]" onClick={onCopy}>
Same as billing
</Button>
)}