Skip to content

Commit d7a899e

Browse files
disable nesting components in html elements
1 parent db048ff commit d7a899e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

app/src/reducers/componentReducer.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ const reducer = (state: State, action: Action) => {
268268
if (childTypeExists('Component', parentComponentId, originalComponent))
269269
return state;
270270
}
271+
271272
let newName = state.HTMLTypes.reduce((name, el) => {
272273
if (typeId === el.id) {
273274
name = type === 'Component' ? componentName : el.tag;
@@ -316,8 +317,14 @@ const reducer = (state: State, action: Action) => {
316317
// 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
317318
else {
318319
directParent = findChild(parentComponent, childId);
319-
directParent.children.push(topSeparator);
320-
directParent.children.push(newChild);
320+
if (directParent.type === "HTML Element" && type === "HTML Element") {
321+
directParent.children.push(topSeparator);
322+
directParent.children.push(newChild);
323+
} else {
324+
console.log('sorry cant drag comp into html bruh')
325+
return state;
326+
}
327+
321328
}
322329
const canvasFocus = {
323330
...state.canvasFocus,

0 commit comments

Comments
 (0)