real forms across the plugin, so enter submits instead of doing nothing

connection settings, add/move/rename/options dialogs and daemon settings all
put their fields in a div, so the button was the only way to submit and enter
silently did nothing — a keyboard trap wearing a layout. wrapped each in a
<form onSubmit>, made every non-submit button in those forms type="button"
(test port, update blocklist, discard, cancel, remove-file, known-dir
shortcuts), and dropped RenameDialog's manual onKeyDown enter check now that
the form handles it natively. the toolbar's filter box is left alone — it has
no submit action.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-19 10:52:36 +00:00
co-authored by Claude Opus 5
parent b26aefd085
commit 17edfa9403
6 changed files with 76 additions and 65 deletions
+13 -11
View File
@@ -1,4 +1,5 @@
import type { Torrent } from '../shared';
import type { FormEvent } from 'react';
import { useEffect, useState } from 'react';
import { Button } from '@/components/ui/button';
import { Checkbox } from '@/components/ui/checkbox';
@@ -67,7 +68,8 @@ export const TorrentOptionsDialog = ({ open, onOpenChange, targets }: TorrentOpt
const patch = (next: Partial<FormState>) => setForm((prev) => (prev ? { ...prev, ...next } : prev));
const submit = async () => {
const submit = async (ev?: FormEvent) => {
ev?.preventDefault();
await set.mutateAsync({
ids: targets.map((t) => t.id),
bandwidthPriority: Number(form.bandwidthPriority),
@@ -98,7 +100,7 @@ export const TorrentOptionsDialog = ({ open, onOpenChange, targets }: TorrentOpt
</DialogDescription>
</DialogHeader>
<div className="space-y-5">
<form onSubmit={submit} className="space-y-5">
<section className="space-y-3">
<h3 className="text-xs font-semibold uppercase tracking-wide text-muted-foreground">Bandwidth</h3>
<div className="grid grid-cols-2 gap-3">
@@ -206,16 +208,16 @@ export const TorrentOptionsDialog = ({ open, onOpenChange, targets }: TorrentOpt
/>
</div>
</section>
</div>
<DialogFooter>
<Button variant="ghost" onClick={() => onOpenChange(false)}>
Cancel
</Button>
<Button onClick={submit} disabled={set.isPending}>
Save
</Button>
</DialogFooter>
<DialogFooter>
<Button type="button" variant="ghost" onClick={() => onOpenChange(false)}>
Cancel
</Button>
<Button type="submit" disabled={set.isPending}>
Save
</Button>
</DialogFooter>
</form>
</DialogContent>
</Dialog>
);