Skip to content

Commit

Permalink
fix(core): fix getClosestPosition error when component nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
bcguan2008 committed Apr 23, 2022
1 parent f34ba4b commit 89cd014
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/core/src/models/MoveHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 89cd014

Please sign in to comment.