SortableJS / Sortable

Reorderable drag-and-drop lists for modern browsers and touch devices. No jQuery or framework required.
https://sortablejs.github.io/Sortable/
MIT License
29.59k stars 3.7k forks source link

Problem using Sortable.utils.select() and multiDragKey #1770

Open joecarl opened 4 years ago

joecarl commented 4 years ago

Problem:

When I call Sortable.utils.select(element) right after Sortable.create I have to manually click on two elements to get it working properly.

In the following JSbin there is a minimal version of the problem.

https://jsbin.com/muciyeluso/edit?html,js,output

As you can see the first item is autoselected, then if I click on the second element both get selected, this is the problem that shouldn't happen, only the second one should be selected after that action (since there's no ctrl key pressed). But then if I click on the third element everything starts working fine.

Is there any workaround to solve this? Or am I missing something?

Thanks in advance.

waynevanson commented 4 years ago

@joecarl Thank you for your example.

Off the top of my head, it's probably something to do with a click event and the Sortable state not syncing up correctly.

Moe-Sumar commented 3 years ago

@joecarl I know this was ages ago but I think this works with

    $('.yourclass').each(function () {
        Sortable.utils.select($(this)[0]);
    });

by owen: https://jsbin.com/qafomak/edit?html,css,js,console,output