@@ -493,26 +493,31 @@ const appStateSlice = createSlice({
493
493
) ;
494
494
// find the moved element's former parent
495
495
// delete the element from it's former parent's children array
496
-
496
+ if ( component ) {
497
497
const { directParent, childIndexValue } = findParent (
498
498
component ,
499
499
currentChildId
500
500
) ;
501
501
// BREAKING HERE during manipulation of positions. Sometimes get a null value when manipulating positions
502
502
// Only run if the directParent exists
503
503
if ( directParent ) {
504
+ if ( directParent . children ) {
504
505
const child = { ...directParent . children [ childIndexValue ] } ;
505
506
directParent . children . splice ( childIndexValue , 1 ) ;
506
507
// if the childId is null, this signifies that we are adding a child to the top level component rather than another child element
507
508
if ( newParentChildId === null ) {
508
509
component . children . push ( child ) ;
510
+
509
511
}
510
512
// if there is a childId (childId here references the direct parent of the new child) find that child and a new child to its children array
511
513
else {
512
514
const directParent = findChild ( component , newParentChildId ) ;
515
+ if ( directParent ?. children ) {
513
516
directParent . children . push ( child ) ;
517
+ }
514
518
}
515
519
}
520
+ }
516
521
let nextTopSeparatorId = state . nextTopSeparatorId ;
517
522
components [ state . canvasFocus . componentId - 1 ] . children =
518
523
manageSeparators . mergeSeparator (
@@ -534,6 +539,8 @@ const appStateSlice = createSlice({
534
539
) ;
535
540
state . components = components ;
536
541
state . nextTopSeparatorId = nextTopSeparatorId ;
542
+
543
+ }
537
544
} ,
538
545
539
546
updateCss : ( state , action ) => {
@@ -543,7 +550,10 @@ const appStateSlice = createSlice({
543
550
components ,
544
551
state . canvasFocus . componentId
545
552
) ;
553
+ // closed if statement at the end of the block
554
+ if ( component && state . canvasFocus . childId ) {
546
555
const targetChild = findChild ( component , state . canvasFocus . childId ) ;
556
+ if ( targetChild ) {
547
557
targetChild . style = style ;
548
558
component . code = generateCode (
549
559
components ,
@@ -555,6 +565,8 @@ const appStateSlice = createSlice({
555
565
action . payload . contextParam
556
566
) ;
557
567
state . components = components ;
568
+ }
569
+ }
558
570
} ,
559
571
560
572
updateAttributes : ( state , action ) => {
@@ -565,8 +577,10 @@ const appStateSlice = createSlice({
565
577
components ,
566
578
state . canvasFocus . componentId
567
579
) ;
580
+ // closed if statement at the end of the block
581
+ if ( component && state . canvasFocus . childId ) {
568
582
const targetChild = findChild ( component , state . canvasFocus . childId ) ;
569
-
583
+ if ( targetChild ) {
570
584
targetChild . attributes = attributes ;
571
585
572
586
component . code = generateCode (
@@ -579,6 +593,8 @@ const appStateSlice = createSlice({
579
593
action . payload . contextParam
580
594
) ;
581
595
state . components = components ;
596
+ }
597
+ }
582
598
} ,
583
599
584
600
updateEvents : ( state , action ) => {
0 commit comments