Skip to content

Commit 737e122

Browse files
committed
WHen change focus compoenet grab the focus child from components array
1 parent ae5ec91 commit 737e122

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/components/Rectangle.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class Rectangle extends Component {
109109
strokeWidth={4}
110110
draggable={false}
111111
/>
112-
{focusChild.childId === childId ? (
112+
{focusChild && focusChild.childId === childId ? (
113113
<TransformerComponent focusComponent={focusComponent} focusChild={focusChild} />
114114
) : (
115115
<Label />

src/utils/componentReducer.util.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,17 @@ console.log(`Real delete component action here : id:${componentId}`)
279279

280280
export const changeFocusComponent = (state, { title }) => {
281281
const newFocusComp = state.components.find(comp => comp.title === title);
282+
// set the "focus child" to the focus child of this particular component .
283+
const newFocusChild = newFocusComp.focusChildId ;
282284

283285
let result = getSelectable(newFocusComp, state.components);
284286

285287
return {
286288
...state,
287289
focusComponent: newFocusComp,
288290
selectableChildren: result.selectableChildren,
289-
ancestors: result.ancestors
291+
ancestors: result.ancestors,
292+
focusChild: newFocusChild,
290293
};
291294
};
292295

0 commit comments

Comments
 (0)