sortable icon indicating copy to clipboard operation
sortable copied to clipboard

Root elements in a nested layout, if all are removed and a new one is dynamically created, lose the handle setting

Open zokistale opened this issue 4 years ago • 4 comments

This code in src/index.js claims to "take care of new items added from Livewire during runtime".

if (directive.modifiers.includes('item-group')) {
    // This will take care of new items added from Livewire during runtime.
    el.closest('[wire\\:sortable-group]').livewire_sortable.addContainer(el)
}

However, it is for sub-sortable lists ('item-group'), not the root list. If instead the root list is emptied and then a new sortable.item is created, the plugin does not add the handle and the entire element is draggable.

I think a similar "take care" block is needed for the root elements, i.e. groups.

zokistale avatar Apr 13 '22 21:04 zokistale

Sure i can confirm this same behavior, also if the initial list of items is empty and then elements are added.

stillzombie avatar May 23 '22 16:05 stillzombie

@stillzombie Thanks for confirming. I still don't have a solution for this, other than forcing non-empty root elements to be added.

zokistale avatar May 24 '22 11:05 zokistale

So for anybody having issues with the handle due a dynamic list when its get empty just add and if statement that only shows the ul when the list is not empty, and then there is not issue anymore with the handle. works nice so maybe this is not an issue @calebporzio

stillzombie avatar May 24 '22 19:05 stillzombie

@stillzombie That may be so, however my reported issue was about nested lists (i.e. sortable lists which have sortable sub-lists inside each of them), not a single sortable list.

zokistale avatar May 25 '22 16:05 zokistale