@@ -370,7 +370,6 @@ export const changeFocusComponent = (state, { title = state.focusComponent.title
370
370
newFocusChild = newFocusComp . childrenArray . find ( child => child . childId === newFocusComp . focusChildId ) ;
371
371
}
372
372
373
- // if no docus child found .. reset
374
373
if ( ! newFocusChild ) {
375
374
newFocusChild = cloneDeep ( state . initialApplicationFocusChild ) ;
376
375
}
@@ -387,9 +386,6 @@ export const changeFocusComponent = (state, { title = state.focusComponent.title
387
386
} ;
388
387
389
388
export const changeFocusChild = ( state , { title, childId } ) => {
390
- // just finds first child with given title, need to pass in specific childId somehow
391
- // maybe default to title if childId is unknown
392
- console . log ( 'change foc comp reducer: childId: ' , childId ) ;
393
389
const focComp = state . components . find ( comp => comp . title === state . focusComponent . title ) ;
394
390
let newFocusChild = focComp . childrenArray . find ( child => child . childId === childId ) ;
395
391
@@ -417,11 +413,12 @@ export const changeFocusChild = (state, { title, childId }) => {
417
413
418
414
export const changeComponentFocusChild = ( state , { componentId, childId } ) => {
419
415
const component = state . components . find ( comp => comp . id === componentId ) ;
420
- component . focusChildId = childId ;
416
+ const modifiedComponent = cloneDeep ( component ) ;
417
+ modifiedComponent . focusChildId = childId ;
421
418
const components = state . components . filter ( comp => comp . id !== componentId ) ;
422
419
return {
423
420
...state ,
424
- components : [ component , ...components ] ,
421
+ components : [ modifiedComponent , ...components ] ,
425
422
} ;
426
423
} ;
427
424
@@ -600,7 +597,7 @@ export const addProp = (state, { key, value = null, required, type }) => {
600
597
nextPropId : selectedComponent . nextPropId + 1 ,
601
598
} ;
602
599
603
- const newComponents = state . components . filter ( comp => comp . id != selectedComponent . id ) ;
600
+ const newComponents = state . components . filter ( comp => comp . id !== selectedComponent . id ) ;
604
601
newComponents . push ( modifiedComponent ) ;
605
602
return {
606
603
...state ,
@@ -610,16 +607,15 @@ export const addProp = (state, { key, value = null, required, type }) => {
610
607
} ;
611
608
612
609
export const deleteProp = ( state , propId ) => {
613
- console . log ( `Hello. Delete prop talking. propId:${ propId } ` ) ;
614
610
if ( ! state . focusComponent . id ) {
615
611
console . log ( 'Delete prop error. no focused component ' ) ;
616
612
return state ;
617
613
}
618
- // make a deep copy of focusCOmponent. we are gonne be modifying that copy
614
+
619
615
const modifiedComponent = cloneDeep ( state . components . find ( comp => comp . id === state . focusComponent . id ) ) ;
620
616
621
617
const indexToDelete = modifiedComponent . props . findIndex ( prop => prop . id === propId ) ;
622
- if ( indexToDelete < 0 ) {
618
+ if ( indexToDelete === - 1 ) {
623
619
console . log ( `Delete prop Error. Prop id:${ propId } not found in ${ modifiedComponent . title } ` ) ;
624
620
return state ;
625
621
}
@@ -645,7 +641,6 @@ export const updateHtmlAttr = (state, { attr, value }) => {
645
641
const modifiedChild = cloneDeep ( state . focusChild ) ;
646
642
modifiedChild . HTMLInfo [ attr ] = value ;
647
643
648
- // make a deep copy of focusCOmponent. we are gonne be modifying that copy
649
644
const modifiedComponent = cloneDeep ( state . components . find ( comp => comp . id === state . focusComponent . id ) ) ;
650
645
651
646
modifiedComponent . childrenArray = modifiedComponent . childrenArray . filter (
0 commit comments