From 581f1ca77eb97e1334eb8c3decf887d65cd81499 Mon Sep 17 00:00:00 2001 From: Siklos Date: Tue, 9 Aug 2022 11:36:58 +0200 Subject: [PATCH] Fix x position when inserting container --- src/Editor.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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