From f3c9ba475ff5484ecbf69b533d04bb6129a7629f Mon Sep 17 00:00:00 2001 From: i33 <78162524@qq.com> Date: Mon, 22 Aug 2022 13:18:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(editor):=20=E6=8B=96=E6=8B=BD=E6=94=B9?= =?UTF-8?q?=E5=8F=98=E7=88=B6=E5=AE=B9=E5=99=A8=E6=97=B6=E9=94=99=E4=B9=B1?= =?UTF-8?q?=E7=8E=B0=E8=B1=A1=20(#296)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(editor): 拖拽改变父容器时错乱现象 直接拖拽元素改变其父容器时, 会产生错乱的现象。 * Update packages/stage/src/types.ts Co-authored-by: jia000 <398009049@qq.com> Co-authored-by: jia000 <398009049@qq.com> --- packages/editor/src/services/editor.ts | 3 ++- packages/stage/src/types.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/editor/src/services/editor.ts b/packages/editor/src/services/editor.ts index 5c3606a7..5460d805 100644 --- a/packages/editor/src/services/editor.ts +++ b/packages/editor/src/services/editor.ts @@ -664,7 +664,8 @@ class Editor extends BaseService { await stage.select(targetId); - await stage.update({ config: cloneDeep(target), parentId: parent.id, root }); + const targetParent = this.getParentById(target.id); + await stage.update({ config: cloneDeep(target), parentId: targetParent?.id, root }); await this.select(newConfig); stage.select(newConfig.id); diff --git a/packages/stage/src/types.ts b/packages/stage/src/types.ts index b983726e..bcaf008c 100644 --- a/packages/stage/src/types.ts +++ b/packages/stage/src/types.ts @@ -119,7 +119,7 @@ export interface SortEventData { export interface UpdateData { config: MNode; parent?: MContainer; - parentId: Id; + parentId?: Id; root: MApp; }