File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
packages/atri-app-core/src Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ type CanvasMachineContext = {
127127 hovered : string | null ;
128128 selected : string | null ;
129129 lastDropped : string | null ; // string until COMPONENT_RENDERED received, otherwise null
130+ newParent : string | null ; // Only used for repositioning
130131} ;
131132
132133// actions
@@ -175,15 +176,15 @@ function setSelectedComponent(
175176}
176177
177178function changeComponentLoc (
178- _context : CanvasMachineContext ,
179+ context : CanvasMachineContext ,
179180 event : MOUSE_UP_EVENT
180181) {
181182 const { target } = event . event ;
182183 if ( target !== null && "closest" in target ) {
183- const comp = ( target as any ) . closest ( "[data-atri-parent]" ) ;
184- if ( comp !== null ) {
185- const compId = comp . getAttribute ( "data-atri-comp-id" ) ;
186- console . log ( "State: changeComponentLoc" , compId ) ;
184+ const parentComp = ( target as any ) . closest ( "[data-atri-parent]" ) ;
185+ if ( parentComp !== null ) {
186+ const parentCompId = parentComp . getAttribute ( "data-atri-comp-id" ) ;
187+ context . newParent = parentCompId ;
187188 }
188189 }
189190}
@@ -340,6 +341,7 @@ export function createCanvasMachine(id: string) {
340341 hovered : null ,
341342 selected : null ,
342343 lastDropped : null ,
344+ newParent : null ,
343345 } ,
344346 states : {
345347 [ initial ] : {
You can’t perform that action at this time.
0 commit comments