Open Maxouhell opened 8 years ago
Is this issue still not fixed, because I have the exact same problem
Same problem here. Still no fix for this?
The problem appears to be caused by the fact that sortable._elem !== sortable._sortableDataService.elem
when ondragover
is called. As far as the component is concerned, when you drag item A over item B, item A's ondragover event is being fired, when instead item B's ondragover event should be fired. I can't find any way of fixing this.
HOWEVER, ondragenter
and ondragleave
seem to fire normally / correctly. I wanted to manually run change detection whenever a sortable list item is dragged over another one (and update the sorting during dragging). I did something like the following which works:
@ViewChildren(SortableComponent) sortables: QueryList<SortableComponent>;
ngAfterViewInit() {
this.sortables.toArray().forEach(sortable => {
sortable._elem.ondragenter = (event) => {
if ((<any>sortable)._isDropAllowed(event)) {
sortable._onDragEnterCallback(event);
this.ref.markForCheck();
}
}
})
}
Report a bug
When I move an element in a list (I use a sortable list), onDragOver isn't fired.
Just create a little list and move elements to see the bug (nothing appear) :
Event must be fired
this._elem != this._sortableDataService.elem
in this file https://github.com/akserg/ng2-dnd/blob/master/src/sortable.component.ts#L134 event is fired but this._elem and this._sortableDataService.elem are identical...Is that a bug, or did I do something wrong ?