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

[bug] Flickering when non-nested elements are moved to a dynamically shown drop zone #2341

Open dertuxmalwieder opened 11 months ago

dertuxmalwieder commented 11 months ago

I have an interesting problem (using latest Chrome-based Edge and Sortable 1.15.1):

I need a sortable list with dynamic drop zones, because I want to be able to either move an element before/after another element or create a new subitem. Overall, it works quite nicely:

8DcT3LnX3a

However, the "it works pretty nice" part ends as soon as the list contains multiple non-nested elements. It looks like Sortable gets confused when calculating the offset:

https://github.com/SortableJS/Sortable/assets/125629/1f124408-b17d-4df0-8760-601ae2cb81d9

In order to make bug hunting easier, here are just the relevant parts:

I suspect that this is - somehow - related to #1686 (which was assumed to be fixed)?

dertuxmalwieder commented 11 months ago

Fix Workaround: Wait a bit before toggling.

{
  //...
  onMove(evt, _originalEvent) {
        $(".drop-container:not(.dont-hide)").addClass("d-none");
        let menuItem = $(evt.related).closest('.menuItem');
        if (menuItem.length > 0) {
            menuItem.find('.drop-container:first').removeClass("d-none");
            menuItem.find('.drop-container:first').addClass("dont-hide");
            setTimeout(() => { $(".wm-dont-hide").removeClass("dont-hide"); }, 100);
        }
  },
}

However, this is far from a good solution in my opinion, or am I missing something?