Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/core/src/utils/sorter/DropLocationDeterminer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class DropLocationDeterminer<T, NodeType extends SortableTreeNode<T>> ext
const { index, placement, placeholderDimensions } = this.getDropPosition(targetNode, mouseX, mouseY);

const placeHolderMoved =
!placeholderDimensions.equals(this.lastMoveData.placeholderDimensions) ||
!placeholderDimensions?.equals(this.lastMoveData.placeholderDimensions) ||
placement !== this.lastMoveData.placement;
if (placeHolderMoved) {
this.eventHandlers.onPlaceholderPositionChange?.(placeholderDimensions!, placement!);
Expand Down Expand Up @@ -249,9 +249,9 @@ export class DropLocationDeterminer<T, NodeType extends SortableTreeNode<T>> ext
let placeholderDimensions = nodeDimensions.clone(),
index = 0,
placement = 'inside' as Placement;
if (nodeHasChildren) {
if (nodeHasChildren && childrenDimensions.length > 0) {
({ index, placement } = findPosition(childrenDimensions, mouseX, mouseY));
placeholderDimensions = childrenDimensions[index].clone();
placeholderDimensions = childrenDimensions[index]?.clone() ?? nodeDimensions.clone();
index = index + (placement == 'after' ? 1 : 0);
}

Expand Down Expand Up @@ -486,6 +486,9 @@ export class DropLocationDeterminer<T, NodeType extends SortableTreeNode<T>> ext
const el = sortableTreeNode.element;
if (!el) return;

// Original logic: include if it's a text node OR matches the item selector
// The issue is that sometimes elements exist in the children array but their
// DOM elements don't match the selector due to timing/state issues
if (!isTextNode(el) && !matches(el, this.containerContext.itemSel)) {
return;
}
Expand Down