Sortable icon indicating copy to clipboard operation
Sortable copied to clipboard

[bug] `Sortable.sort()` with non-draggable items doesn't work properly

Open aintyourcat opened this issue 2 years ago • 1 comments

Describe the bug

Whenever sort() called on a sortable element which has one or more non-draggable items, it will sort them weirdly.

To Reproduce Steps to reproduce the behavior:

  1. Go to this JS Bin.
  2. Try to move an item without removing any item first, it sorts the items properly.
  3. Remove an item or more, then move an item, it sorts the existing items unexpectedly.

Expected behavior

sort() should sort the existing items like how it sort items on a sortable element with no non-draggable items.

Information

sortablejs = 1.15.0

Additional context None.

Reproduction codesandbox: -

aintyourcat avatar Mar 27 '23 13:03 aintyourcat

I came to this issue due to a similar issue, but I was also dealing with a Svelte.

To fix my problem, I set forceFallback: true which counters the default HTML5 DnD behavior (which sets draggable=false. Because of Svelte's behavior, I had to use an afterUpdate() to set all the items in my list back to draggable=true

I'm thinking we're dealing with the same root cause.

Merovex avatar May 17 '23 10:05 Merovex