Skip to content

Commit

Permalink
fix(mind): fix move issue for collapsed mind element
Browse files Browse the repository at this point in the history
  • Loading branch information
pubuzhixing8 committed Dec 21, 2024
1 parent e4beff4 commit 60b57e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/core/src/core/list-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlaitElement>) => {
NODE_TO_INDEX.set(record.item, record.currentIndex as number);
Expand Down Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/interfaces/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 60b57e0

Please sign in to comment.