diff --git a/src/Editor.tsx b/src/Editor.tsx index e085355..b983744 100644 --- a/src/Editor.tsx +++ b/src/Editor.tsx @@ -248,9 +248,11 @@ class Editor extends React.Component { } let x = 0; - const lastChild: IContainerModel | undefined = parentClone.children.at(-1); - if (lastChild !== undefined) { - x = lastChild.properties.x + Number(lastChild.properties.width); + if (index !== 0) { + const lastChild: IContainerModel | undefined = parentClone.children.at(index - 1); + if (lastChild !== undefined) { + x = lastChild.properties.x + Number(lastChild.properties.width); + } } // Create the container