@@ -778,29 +778,31 @@ async function handleBlocksOperationTx(
778778
779779 const isRemovingFromParent = ! parentId
780780
781- // Get current data to update
781+ // Get current data and position
782782 const [ currentBlock ] = await tx
783- . select ( { data : workflowBlocks . data } )
783+ . select ( {
784+ data : workflowBlocks . data ,
785+ positionX : workflowBlocks . positionX ,
786+ positionY : workflowBlocks . positionY ,
787+ } )
784788 . from ( workflowBlocks )
785789 . where ( and ( eq ( workflowBlocks . id , id ) , eq ( workflowBlocks . workflowId , workflowId ) ) )
786790 . limit ( 1 )
787791
788792 const currentData = currentBlock ?. data || { }
789793
790- // Update data with parentId and extent
791794 const updatedData = isRemovingFromParent
792- ? { } // Clear data entirely when removing from parent
795+ ? { }
793796 : {
794797 ...currentData ,
795798 ...( parentId ? { parentId, extent : 'parent' } : { } ) ,
796799 }
797800
798- // Update position and data
799801 await tx
800802 . update ( workflowBlocks )
801803 . set ( {
802- positionX : position ?. x ?? currentBlock ?. data ?. positionX ,
803- positionY : position ?. y ?? currentBlock ?. data ?. positionY ,
804+ positionX : position ?. x ?? currentBlock ?. positionX ?? 0 ,
805+ positionY : position ?. y ?? currentBlock ?. positionY ?? 0 ,
804806 data : updatedData ,
805807 updatedAt : new Date ( ) ,
806808 } )
0 commit comments