Sortable icon indicating copy to clipboard operation
Sortable copied to clipboard

[bug] Fallback mode includes cloned element in toArray

Open juniwalk opened this issue 2 months ago • 2 comments

Describe the bug

I am using toArray() method in onStart and in onSort to calculate difference in positions. However on my phone (in fallback mode) it was giving me larger array from onStart then onSort.

To me it looks like toArray() is including cloned element from fallback mode.

To Reproduce Steps to reproduce the behavior:

  • Create sortable list with data-id attributes
  • Force fallback to be enabled
  • Log toArray on onStart and onSort
  • See that log from onStart has more elements

Expected behavior

I think cloned element should not have the [data-id] attribute so it would not be in the toArray

Information

Versions - Look in your package.json for this information: sortablejs = ^1.15.6 @types/sortablejs = not used

Additional context Add any other context about the problem here.

Reproduction codesandbox: https://f2hf5l.csb.app/

juniwalk avatar Nov 15 '25 10:11 juniwalk

yep, its a problem. especially if it gets re-rendered. for me solved it to re-calc the arrray quickly

fanvyr avatar Nov 20 '25 01:11 fanvyr

@fanvyr Yeah I have a workaround also I just wanted to post the issue.

juniwalk avatar Nov 20 '25 09:11 juniwalk