@@ -30,6 +30,7 @@ partial class WorkspaceViewModel
3030
3131 private readonly StateMachine stateMachine = null ;
3232 private List < DraggedNode > draggedNodes = new List < DraggedNode > ( ) ;
33+ private Dictionary < Guid , Point > draggedGroupOriginalPositions = new ( ) ;
3334
3435 // When a new connector is created or a single connector is selected,
3536 // activeConnectors has array size of 1.
@@ -65,7 +66,8 @@ partial class WorkspaceViewModel
6566 [ JsonIgnore ]
6667 internal ConnectorViewModel FirstActiveConnector
6768 {
68- get {
69+ get
70+ {
6971 if ( null != activeConnectors && activeConnectors . Count ( ) > 0 )
7072 {
7173 return activeConnectors [ 0 ] ;
@@ -149,6 +151,14 @@ internal void BeginDragSelection(Point2D mouseCursor)
149151 {
150152 throw new InvalidOperationException ( Wpf . Properties . Resources . InvalidDraggingOperationMessgae ) ;
151153 }
154+
155+ // Track original positions of any selected annotation groups at the beginning of a drag
156+ // This allows us to later determine whether the group was truly moved or just clicked
157+ draggedGroupOriginalPositions . Clear ( ) ;
158+ foreach ( var group in DynamoSelection . Instance . Selection . OfType < AnnotationModel > ( ) )
159+ {
160+ draggedGroupOriginalPositions [ group . GUID ] = new Point ( group . X , group . Y ) ;
161+ }
152162 }
153163
154164 internal void UpdateDraggedSelection ( Point2D mouseCursor )
@@ -763,6 +773,28 @@ internal bool HandleMouseRelease(object sender, MouseButtonEventArgs e)
763773 . OfType < AnnotationModel > ( )
764774 . ToList ( ) ;
765775
776+ // DYN-8893: Prevent accidental grouping when overlapping groups are clicked without dragging
777+ // If a group visually overlaps another and is simply clicked (not dragged),
778+ // grouping can be mistakenly triggered. To avoid this, we record original positions
779+ // of dragged groups and compare them on mouse release. Grouping only proceeds if
780+ // a group was actually moved. This check is skipped if only nodes are selected
781+ bool anyGroupMoved = dragedGroups . All ( group =>
782+ {
783+ if ( ! owningWorkspace . draggedGroupOriginalPositions . TryGetValue ( group . GUID , out var originalPos ) )
784+ return true ; // Assume moved if not tracked
785+
786+ var current = group . Position ;
787+ return Math . Abs ( originalPos . X - current . X ) > 0.1 && Math . Abs ( originalPos . Y - current . Y ) > 0.1 ;
788+ } ) ;
789+
790+ // If we're dealing with groups and none of them moved, we shouldn't group them
791+ if ( ! anyGroupMoved && dragedGroups . Any ( ) )
792+ {
793+ dropGroup . NodeHoveringState = false ;
794+ SetCurrentState ( State . None ) ;
795+ return false ;
796+ }
797+
766798 // We do not want to add dragged groups content twice
767799 // so we filter it out here.
768800 var modelsToAdd = DynamoSelection . Instance . Selection
0 commit comments