fix(editor): 移动元素到容器中的时候root没有更新问题 (#569)

* fix(editor/stage): 拖动组件进画布后,父容器位置计算有误

* fix(editorService): 移动元素时候root没有更新问题

---------

Co-authored-by: fanliming <fanlm@novastar.tech>
This commit is contained in:
leon Li 2024-01-18 11:39:37 +08:00 committed by GitHub
parent 30929e8bd3
commit edc7c11929
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -810,7 +810,7 @@ class Editor extends BaseService {
* @param targetId ID
*/
public async moveToContainer(config: MNode, targetId: Id): Promise<MNode | undefined> {
const root = cloneDeep(this.get('root'));
const root = this.get('root');
const { node, parent } = this.getNodeInfo(config.id, false);
const target = this.getNodeById(targetId, false) as MContainer;
@ -819,7 +819,7 @@ class Editor extends BaseService {
const index = getNodeIndex(node.id, parent);
parent.items?.splice(index, 1);
await stage.remove({ id: node.id, parentId: parent.id, root });
await stage.remove({ id: node.id, parentId: parent.id, root: cloneDeep(root) });
const layout = await this.getLayout(target);
@ -835,7 +835,7 @@ class Editor extends BaseService {
await stage.select(targetId);
const targetParent = this.getParentById(target.id);
await stage.update({ config: cloneDeep(target), parentId: targetParent?.id, root });
await stage.update({ config: cloneDeep(target), parentId: targetParent?.id, root: cloneDeep(root) });
await this.select(newConfig);
stage.select(newConfig.id);