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.6k stars 3.7k forks source link

Option to keep selection on multiDrag and clone behaviour #1786

Open JPernerstorfer opened 4 years ago

JPernerstorfer commented 4 years ago

Is there a way to keep the selection of the items you have multiDragged?

waynevanson commented 4 years ago

@JPernerstorfer This doesn't make sense to me. If you have multidrag enabled, all selected elements will move together.

Could you be more specific?

JPernerstorfer commented 4 years ago

Hi @waynevanson , yeah sorry, it was not really clear. What I meant was to keep the selection after droping the elements somewhere. When you drop the items, you loose the selection of the multidragged items.

E.g.: I have a list of dishes, and a list for each day of a week, I would like and option to select 3 dishes, drag them to monday, and still have them selected on the original list, so I would be able to drag them again to another list/day.

Right now I am using a hack using what is mentioned here. But it is not the exact behaviour I need.

I was thinking something along the lines of "option.keepSelectionAfterDrop".

Also, this way, if you accidentally drop the items in an empty space (like missing the list or letting go of the mouse button to soon) you do not lose the selection.

Best Regards

Slos commented 4 years ago

Hi,

I would like to have the opposite behaviour. For me, after dropping the multidrag items, they remain selected. I would like to get them all deselected after dropping. :)

Also it would be great to have manual control over select and deselect events. There seems to be a gap somewhere in the code...

I can catch the select event and execute a deselect(item), but only once. When the code hits the onSelect(item) method on the sortable for a second time, Sortable.utils.deselect(item) misbehaves. The sortable options.isMultidrag option is set to undefined on the second pass, on the first pass this option is 'true' (as it should be).

This works only on the first call: Sortable.utils.deselect($(event.target).closest('.list-group-item')[0])

there seem to be quite a few issues reports related to select/deselect events.