@@ -20,7 +20,7 @@ import {
20
20
import { createLinkConnectorAdapter } from '@/renderer/core/canvas/links/linkConnectorAdapter'
21
21
import type { LinkConnectorAdapter } from '@/renderer/core/canvas/links/linkConnectorAdapter'
22
22
import {
23
- resolveNodeSurfaceCandidate ,
23
+ resolveNodeSurfaceSlotCandidate ,
24
24
resolveSlotTargetCandidate
25
25
} from '@/renderer/core/canvas/links/linkDropOrchestrator'
26
26
import {
@@ -330,7 +330,7 @@ export function useSlotLinkInteraction({
330
330
const slotCandidate = resolveSlotTargetCandidate ( target , context )
331
331
const nodeCandidate = slotCandidate
332
332
? null
333
- : resolveNodeSurfaceCandidate ( target , context )
333
+ : resolveNodeSurfaceSlotCandidate ( target , context )
334
334
candidate = slotCandidate ?? nodeCandidate
335
335
dragContext . lastHoverSlotKey = hoveredSlotKey
336
336
dragContext . lastHoverNodeId = hoveredNodeId
@@ -498,37 +498,14 @@ export function useSlotLinkInteraction({
498
498
return
499
499
}
500
500
501
- // Prefer using the snapped candidate captured during hover for perf + consistency
502
501
const snappedCandidate = state . candidate ?. compatible
503
502
? state . candidate
504
503
: null
505
504
506
- let connected = tryConnectToCandidate ( snappedCandidate )
505
+ const hasConnected = connectByPriority ( canvasEvent . target , snappedCandidate )
507
506
508
- // Fallback to DOM slot under pointer (if any), then node fallback, then reroute
509
- if ( ! connected ) {
510
- const adapter = activeAdapter
511
- const graph = app . canvas ?. graph ?? null
512
- const context = { adapter, graph, session : dragContext }
513
- const domCandidate = resolveSlotTargetCandidate (
514
- canvasEvent . target ,
515
- context
516
- )
517
- connected = tryConnectToCandidate ( domCandidate )
518
-
519
- if ( ! connected ) {
520
- const nodeCandidate = resolveNodeSurfaceCandidate (
521
- canvasEvent . target ,
522
- context
523
- )
524
- connected = tryConnectToCandidate ( nodeCandidate )
525
- }
526
- }
527
-
528
- if ( ! connected ) connected = tryConnectViaRerouteAtPointer ( ) || connected
529
-
530
- if ( ! connected ) {
531
- if ( activeAdapter ) activeAdapter . dropOnCanvas ( canvasEvent )
507
+ if ( ! hasConnected ) {
508
+ activeAdapter ?. dropOnCanvas ( canvasEvent )
532
509
}
533
510
534
511
cleanupInteraction ( )
@@ -548,6 +525,34 @@ export function useSlotLinkInteraction({
548
525
app . canvas ?. setDirty ( true , true )
549
526
}
550
527
528
+ function connectByPriority (
529
+ target : EventTarget | null ,
530
+ snappedCandidate : SlotDropCandidate | null
531
+ ) : boolean {
532
+ const adapter = activeAdapter
533
+ const graph = app . canvas ?. graph ?? null
534
+ const context = { adapter, graph, session : dragContext }
535
+
536
+ const attemptSnapped = ( ) => tryConnectToCandidate ( snappedCandidate )
537
+
538
+ const domSlotCandidate = resolveSlotTargetCandidate ( target , context )
539
+ const attemptDomSlot = ( ) => tryConnectToCandidate ( domSlotCandidate )
540
+
541
+ const nodeSurfaceSlotCandidate = resolveNodeSurfaceSlotCandidate (
542
+ target ,
543
+ context
544
+ )
545
+ const attemptNodeSurface = ( ) =>
546
+ tryConnectToCandidate ( nodeSurfaceSlotCandidate )
547
+ const attemptReroute = ( ) => tryConnectViaRerouteAtPointer ( )
548
+
549
+ if ( attemptSnapped ( ) ) return true
550
+ if ( attemptDomSlot ( ) ) return true
551
+ if ( attemptNodeSurface ( ) ) return true
552
+ if ( attemptReroute ( ) ) return true
553
+ return false
554
+ }
555
+
551
556
const onPointerDown = ( event : PointerEvent ) => {
552
557
if ( event . button !== 0 ) return
553
558
if ( ! nodeId ) return
0 commit comments