diff --git a/src/app/utilities/rete-editor.ts b/src/app/utilities/rete-editor.ts index 7fc14ed..46c61da 100644 --- a/src/app/utilities/rete-editor.ts +++ b/src/app/utilities/rete-editor.ts @@ -225,9 +225,15 @@ export async function createEditor( }); area.addPipe((context: any) => { - // The connection renderer raises only the selected wire. A picked node is about to be dragged, - // so clear that selection before its card can be drawn below the wire. - if (context?.type === 'nodepicked') graphSelection.clearConnectionSelection(); + // The connection renderer raises only the selected wire. Clear it before dragging an unrelated + // card, but keep it when the picked card is one of the wire's own endpoints. + if (context?.type === 'nodepicked') { + const selected = graphSelection.selectedConnection(); + const nodeId = String(context.data?.id ?? ''); + if (!selected || (nodeId !== selected.sourceId && nodeId !== selected.targetId)) { + graphSelection.clearConnectionSelection(); + } + } if (context?.type === 'nodetranslated') { // A loop follows only its own endpoints. A card merely crossed by the wire must not make the // wire move away, while moving either endpoint keeps the wire 48px above that endpoint.