From 7cc2ddc6ad97647009ebeacc7328322eb971d266 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 31 May 2026 19:17:34 +0200 Subject: [PATCH] refactor(stammbaum): carry child id on the connector centre object (#703) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The shared parent-pair child loop read group.childIds[i] while iterating the filtered childCenters, so a child without a position would desync the id from the centre — and that index now also drives the active-connector lookup. Ride the id on the mapped {id,x,y} centre so the two never drift; a positionless child drops out of both together. Co-Authored-By: Claude Opus 4.8 --- .../person/genealogy/StammbaumConnectors.svelte | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/frontend/src/lib/person/genealogy/StammbaumConnectors.svelte b/frontend/src/lib/person/genealogy/StammbaumConnectors.svelte index 624323ca..57acf7df 100644 --- a/frontend/src/lib/person/genealogy/StammbaumConnectors.svelte +++ b/frontend/src/lib/person/genealogy/StammbaumConnectors.svelte @@ -106,8 +106,11 @@ const parentLinks = $derived.by(() => { {@const aCenter = nodeCenter(group.parentA)} {@const bCenter = nodeCenter(group.parentB)} {@const childCenters = group.childIds - .map((id) => nodeCenter(id)) - .filter((c): c is { x: number; y: number } => c !== null)} + .map((id) => { + const c = nodeCenter(id); + return c ? { id, x: c.x, y: c.y } : null; + }) + .filter((c): c is { id: string; x: number; y: number } => c !== null)} {#if aCenter && bCenter && childCenters.length > 0} {@const midX = (aCenter.x + bCenter.x) / 2} {@const parentBottomY = aCenter.y + NODE_H / 2} @@ -138,13 +141,14 @@ const parentLinks = $derived.by(() => { /> {/if} - {#each childCenters as cc, i (group.childIds[i])} + {#each childCenters as cc (cc.id)} + to the lineage child while dimming to a collateral sibling. The child + id rides on the centre object, so it never desyncs from the filtered + centres (a child without a position drops out of both together). --> {@const childActive = - isConnectorActive(group.parentA, group.childIds[i]) && - isConnectorActive(group.parentB, group.childIds[i])} + isConnectorActive(group.parentA, cc.id) && isConnectorActive(group.parentB, cc.id)}