diff --git a/src/Editor.tsx b/src/Editor.tsx index 8b4edb6..5e24be6 100644 --- a/src/Editor.tsx +++ b/src/Editor.tsx @@ -212,13 +212,19 @@ class Editor extends React.Component { throw new Error('[OnPropertyChange] Container model was not found among children of the main container!'); } + let x = 0; + const lastChild: IContainerModel | undefined = parent.children.at(-1); + if (lastChild !== undefined) { + x = lastChild.properties.x + Number(lastChild.properties.width); + } + // Create the container const newContainer = new ContainerModel( parent, { id: `${type}-${count}`, parentId: parent.properties.id, - x: 0, + x, y: 0, width: properties?.Width, height: parent.properties.height,