diff --git a/packages/core/src/core/list-render.ts b/packages/core/src/core/list-render.ts index 289afeb89..90a0b3ff9 100644 --- a/packages/core/src/core/list-render.ts +++ b/packages/core/src/core/list-render.ts @@ -52,6 +52,7 @@ export class ListRender { if (diffResult) { const newContexts: PlaitPluginElementContext[] = []; const newInstances: ElementFlavour[] = []; + // for moving scene: the current index for first element before moving let currentIndexForFirstElement: number | null = null; diffResult.forEachItem((record: IterableChangeRecord) => { NODE_TO_INDEX.set(record.item, record.currentIndex as number); @@ -235,7 +236,7 @@ const mountOnItemMove = ( ) => { const containerG = PlaitElement.getContainerG(element, { suppressThrow: false }); mountElementG(index, containerG, childrenContext, currentIndexForFirstElement); - if (element.children && !PlaitElement.isRootElement(element)) { + if (element.children && !PlaitElement.isRootElement(element) && childrenContext.board.isExpanded(element)) { element.children.forEach((child, index) => { mountOnItemMove(child, index, { ...childrenContext, parent: element }, null); }); diff --git a/packages/core/src/interfaces/node.ts b/packages/core/src/interfaces/node.ts index 0a8bc479b..ddee97ba7 100644 --- a/packages/core/src/interfaces/node.ts +++ b/packages/core/src/interfaces/node.ts @@ -50,7 +50,7 @@ export const PlaitNode = { first(board: PlaitBoard, path: Path) { const p = path.slice(); let n = PlaitNode.get(board, p); - if (!n.children) { + if (!n.children || !board.isExpanded(n)) { return n; } while (n) {