Skip to content

Commit 3eb3564

Browse files
authored
fix the drag position problem when existing non draggable elements at the end of the list
When dragging an element to the end of the list, and existing non draggable elements at the end of the list. Appending it to the end of the list is not incorrect, It should be inserted before the next sibling of the last draggable element.
1 parent 21f7ede commit 3eb3564

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Sortable.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,12 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
11881188

11891189
if (onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
11901190
capture();
1191-
el.appendChild(dragEl);
1191+
if (elLastChild && elLastChild.nextSibling) { // the last draggable element is not the last node
1192+
el.insertBefore(dragEl, elLastChild.nextSibling);
1193+
}
1194+
else {
1195+
el.appendChild(dragEl);
1196+
}
11921197
parentEl = el; // actualization
11931198

11941199
changed();

0 commit comments

Comments
 (0)