Closed jessefoster closed 9 years ago
UI-Sortable's README clearly states that:
ui-sortable element should only contain one ng-repeat and not any other elements (above or below). Otherwise the index matching of the generated DOM elements and the ng-model's items will break. In other words: The items of ng-model must match the indexes of the generated DOM elements.
This is already solved in UI-Sortable v0.14.x-dev branch, but not in any implementation of ui-sortable-multiselection. Thanks for your effort.
I have placeholder text in one of my dropzones. After multiple items are dropped the index is incorrectly calculated as it considers the placeholder text as part of the sortable list. Here's a live example, http://codepen.io/anon/pen/jbLYqa. Whatever item you use to drag the list is inserted first.
The origin of this bug is in ui-sortable as it provides the index you're using from ui.item.sortable.dropindex.
I tried working around this issue within ui-sortable-multiselection but couldn't find a clean way since ui-sortable modifies the DOM before your methods are called.
I did put together a possible fix in my fork of ui-sortable, jessefoster/ui-sortable@7a394a6d4bdb728b86d7f1a6ed693910cf2ec216