Fix spending edges to use explicit bottom handle + enable edge reconnection

- Added explicit 'spending-out' ID to bottom handle on funnels
- Spending edges now explicitly connect from bottom handle
- Enable edgesReconnectable so users can drag edges to different handles
- Added onReconnect handler for edge re-attachment

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2026-01-29 23:07:04 +00:00
parent 29b68d5770
commit 1f44e292f7
2 changed files with 12 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import {
useNodesState, useNodesState,
useEdgesState, useEdgesState,
addEdge, addEdge,
reconnectEdge,
Connection, Connection,
MarkerType, MarkerType,
Panel, Panel,
@ -252,7 +253,7 @@ function generateEdges(nodes: FlowNode[]): FlowEdge[] {
id: `spending-${node.id}-${alloc.targetId}`, id: `spending-${node.id}-${alloc.targetId}`,
source: node.id, source: node.id,
target: alloc.targetId, target: alloc.targetId,
sourceHandle: undefined, // Default bottom sourceHandle: 'spending-out', // Explicit bottom handle
animated: true, animated: true,
style: { style: {
stroke: alloc.color, stroke: alloc.color,
@ -298,6 +299,13 @@ export default function FlowCanvas() {
[setEdges] [setEdges]
) )
// Allow edges to be reconnected by dragging
const onReconnect = useCallback(
(oldEdge: FlowEdge, newConnection: Connection) =>
setEdges((eds) => reconnectEdge(oldEdge, newConnection, eds) as FlowEdge[]),
[setEdges]
)
// Simulation effect // Simulation effect
useEffect(() => { useEffect(() => {
if (!isSimulating) return if (!isSimulating) return
@ -350,7 +358,9 @@ export default function FlowCanvas() {
onNodesChange={onNodesChange} onNodesChange={onNodesChange}
onEdgesChange={onEdgesChange} onEdgesChange={onEdgesChange}
onConnect={onConnect} onConnect={onConnect}
onReconnect={onReconnect}
nodeTypes={nodeTypes} nodeTypes={nodeTypes}
edgesReconnectable={true}
fitView fitView
fitViewOptions={{ padding: 0.15 }} fitViewOptions={{ padding: 0.15 }}
className="bg-slate-50" className="bg-slate-50"

View File

@ -618,6 +618,7 @@ function FunnelNode({ data, selected, id }: NodeProps) {
<Handle <Handle
type="source" type="source"
position={Position.Bottom} position={Position.Bottom}
id="spending-out"
className="!w-4 !h-4 !bg-blue-500 !border-2 !border-white !-bottom-2" className="!w-4 !h-4 !bg-blue-500 !border-2 !border-white !-bottom-2"
/> />
</div> </div>