From 89cd01424ff2271c7e53c7332fd6126e19d73aa1 Mon Sep 17 00:00:00 2001 From: guanbingchagn <148135244@qq.com> Date: Sat, 23 Apr 2022 08:27:53 +0800 Subject: [PATCH] fix(core): fix getClosestPosition error when component nesting --- packages/core/src/models/MoveHelper.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/core/src/models/MoveHelper.ts b/packages/core/src/models/MoveHelper.ts index da4a0fd75..c2325b116 100644 --- a/packages/core/src/models/MoveHelper.ts +++ b/packages/core/src/models/MoveHelper.ts @@ -111,12 +111,12 @@ export class MoveHelper { const closestNode = this.closestNode if (!closestNode || !viewport.isPointInViewport(point)) return ClosestPosition.Forbid - const closestRect = viewport.getValidNodeRect(closestNode) + let closestRect = viewport.getValidNodeRect(closestNode) const isInline = this.getClosestLayout(viewport) === 'horizontal' if (!closestRect) { return } - const isAfter = isNearAfter( + let isAfter = isNearAfter( point, closestRect, viewport.moveInsertionType === 'block' ? false : isInline @@ -132,7 +132,14 @@ export class MoveHelper { const parentClosestNode = getValidParent(closestNode) if (parentClosestNode) { this.closestNode = parentClosestNode + closestRect = viewport.getValidNodeRect(this.closestNode) + isAfter = isNearAfter( + point, + closestRect, + viewport.moveInsertionType === 'block' ? false : isInline + ) } + if (isInline) { if (parentClosestNode) { if (isAfter) { @@ -177,9 +184,17 @@ export class MoveHelper { } else { if (!closestNode.allowSibling(this.dragNodes)) { const parentClosestNode = getValidParent(closestNode) + if (parentClosestNode) { this.closestNode = parentClosestNode + closestRect = viewport.getValidNodeRect(this.closestNode) + isAfter = isNearAfter( + point, + closestRect, + viewport.moveInsertionType === 'block' ? false : isInline + ) } + if (isInline) { if (parentClosestNode) { if (isAfter) {