Sortable icon indicating copy to clipboard operation
Sortable copied to clipboard

[bug] Significant lag when shift-selecting large data set range with MultiDrag

Open jbish55 opened this issue 3 years ago • 2 comments

Describe the bug

When attempting to shift+select a large number of items (500+) to move to another list there is a significant lag (~1 second per 100 items).

To Reproduce I've created a rough test jsbin with 1000 items for testing: https://jsbin.com/weraxoroho/edit?html,js,output Steps to reproduce the behavior:

  1. Select the first item
  2. Scroll to the bottom of the first list and select the last item while holding SHIFT
  3. Wait about 10 seconds before they're all selected (will turn green)

Expected behavior

The expected behavior is an instant selection of all items with no lag.

Information

sortablejs = 1.15.0

Additional context The same lag is found in Chrome, Firefox, and Safari. Doing some digging into the codebase, I was able to track down the suspected culprit of the lag.

On Line 3514 is the for loop that handles each element within the Shift+select range Within that loop it calls dispatchEvent() and within that function is a call to _objectSpread2() on Line 948

https://github.com/SortableJS/Sortable/blob/babf6ab85fdfc5e13be1027827cecfbba2fb0d1e/Sortable.js#L948

Commenting out this line along with lines 950-952, it works blazing fast and selects everything as expected.

Can _objectSpread2() be better optimized? Or is there a work around for MultiDrag with large data sets?

jbish55 avatar Aug 31 '22 17:08 jbish55

+1, interested in developments for large scale data

tomasmenezes avatar Nov 05 '22 00:11 tomasmenezes

+1

zbigniewkuminski avatar Feb 08 '23 13:02 zbigniewkuminski