@@ -383,7 +383,6 @@ export const changeFocusComponent = (state, { title = state.focusComponent.title
383
383
) ;
384
384
}
385
385
386
- // if no docus child found .. reset
387
386
if ( ! newFocusChild ) {
388
387
newFocusChild = cloneDeep ( state . initialApplicationFocusChild ) ;
389
388
}
@@ -400,9 +399,6 @@ export const changeFocusComponent = (state, { title = state.focusComponent.title
400
399
} ;
401
400
402
401
export const changeFocusChild = ( state , { title, childId } ) => {
403
- // just finds first child with given title, need to pass in specific childId somehow
404
- // maybe default to title if childId is unknown
405
- console . log ( 'change foc comp reducer: childId: ' , childId ) ;
406
402
const focComp = state . components . find ( comp => comp . title === state . focusComponent . title ) ;
407
403
let newFocusChild = focComp . childrenArray . find ( child => child . childId === childId ) ;
408
404
@@ -430,11 +426,12 @@ export const changeFocusChild = (state, { title, childId }) => {
430
426
431
427
export const changeComponentFocusChild = ( state , { componentId, childId } ) => {
432
428
const component = state . components . find ( comp => comp . id === componentId ) ;
433
- component . focusChildId = childId ;
429
+ const modifiedComponent = cloneDeep ( component ) ;
430
+ modifiedComponent . focusChildId = childId ;
434
431
const components = state . components . filter ( comp => comp . id !== componentId ) ;
435
432
return {
436
433
...state ,
437
- components : [ component , ...components ] ,
434
+ components : [ modifiedComponent , ...components ] ,
438
435
} ;
439
436
} ;
440
437
@@ -615,7 +612,7 @@ export const addProp = (state, {
615
612
nextPropId : selectedComponent . nextPropId + 1 ,
616
613
} ;
617
614
618
- const newComponents = state . components . filter ( comp => comp . id != selectedComponent . id ) ;
615
+ const newComponents = state . components . filter ( comp => comp . id !== selectedComponent . id ) ;
619
616
newComponents . push ( modifiedComponent ) ;
620
617
return {
621
618
...state ,
@@ -625,18 +622,17 @@ export const addProp = (state, {
625
622
} ;
626
623
627
624
export const deleteProp = ( state , propId ) => {
628
- console . log ( `Hello. Delete prop talking. propId:${ propId } ` ) ;
629
625
if ( ! state . focusComponent . id ) {
630
626
console . log ( 'Delete prop error. no focused component ' ) ;
631
627
return state ;
632
628
}
633
- // make a deep copy of focusCOmponent. we are gonne be modifying that copy
629
+
634
630
const modifiedComponent = cloneDeep (
635
631
state . components . find ( comp => comp . id === state . focusComponent . id ) ,
636
632
) ;
637
633
638
634
const indexToDelete = modifiedComponent . props . findIndex ( prop => prop . id === propId ) ;
639
- if ( indexToDelete < 0 ) {
635
+ if ( indexToDelete === - 1 ) {
640
636
console . log ( `Delete prop Error. Prop id:${ propId } not found in ${ modifiedComponent . title } ` ) ;
641
637
return state ;
642
638
}
@@ -662,7 +658,6 @@ export const updateHtmlAttr = (state, { attr, value }) => {
662
658
const modifiedChild = cloneDeep ( state . focusChild ) ;
663
659
modifiedChild . HTMLInfo [ attr ] = value ;
664
660
665
- // make a deep copy of focusCOmponent. we are gonne be modifying that copy
666
661
const modifiedComponent = cloneDeep (
667
662
state . components . find ( comp => comp . id === state . focusComponent . id ) ,
668
663
) ;
0 commit comments