Skip to content

ui-sortable sort dom becomes out of sync #5

@ghost

Description

Hello,

I have noticed a few weird bugs with using ui-sortable component which I'm still in process of debugging:

  1. when moving sortable items quickly which calls the moved" action to sync up the sort order to the original content array using the old and the next indexes, for whatever reason the sortable dom eventually becomes out of sync relative to the actual order of the original content, ie:. this may not be noticeable when moving items at lower frequency.

  2. if attempting a sort, and then followed by deleting the item (which simply removes the item from the content array), the corresponding sortable dom element will not be removed.
    deleting items works fine if no sort is performed beforehand. likely required in this case to update the indexes on delete (data attributes), something like this may do:

        let index = 0;
        this.$().children().each(function(i) { 
          Ember.$(this).data('oldIndex', index);
          index++;
        });

this out of sync problem problems seems like it can be solved utilizing the ember run loop and syncing the items "oldIndex" data attribute on the elements, and in the case of delete also ui.item.remove() required, but I can't say for sure now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions