diff --git a/ui/src/pages/ExtrasPage.tsx b/ui/src/pages/ExtrasPage.tsx index 8b5faae4b..9dc5d1426 100644 --- a/ui/src/pages/ExtrasPage.tsx +++ b/ui/src/pages/ExtrasPage.tsx @@ -24,12 +24,21 @@ import { useT } from '../i18n'; // ─── AddExtraModal ──────────────────────────────────────────────────────────── interface TargetEntry { + id: string; // stable React key — paths can be empty/duplicate while editing path: string; mode: string; flatten: boolean; extension: string; } +const newTarget = (): TargetEntry => ({ + id: crypto.randomUUID(), + path: '', + mode: 'merge', + flatten: false, + extension: '', +}); + const MODE_OPTIONS = [ { value: 'merge', label: 'merge', description: 'Per-file symlinks, preserves local files' }, { value: 'copy', label: 'copy', description: 'Copy files to target directory' }, @@ -49,10 +58,10 @@ function AddExtraModal({ const t = useT(); const [name, setName] = useState(''); const [source, setSource] = useState(''); - const [targets, setTargets] = useState([{ path: '', mode: 'merge', flatten: false, extension: '' }]); + const [targets, setTargets] = useState(() => [newTarget()]); const [saving, setSaving] = useState(false); - const addTarget = () => setTargets((prev) => [...prev, { path: '', mode: 'merge', flatten: false, extension: '' }]); + const addTarget = () => setTargets((prev) => [...prev, newTarget()]); const updateTarget = (i: number, field: keyof TargetEntry, value: string | boolean) => { setTargets((prev) => prev.map((t, idx) => (idx === i ? { ...t, [field]: value } : t))); @@ -148,7 +157,7 @@ function AddExtraModal({ {targets.map((tgt, i) => { const fieldLabel = 'block text-xs font-medium text-pencil-light mb-1'; return ( -
+
{/* Path — full width, like Name / Source above */}
@@ -372,8 +381,8 @@ function ExtraCard({
{extra.targets.length > 0 ? ( - extra.targets.map((tgt, ti) => ( -
+ extra.targets.map((tgt) => ( +
{tgt.path}