Objective: Create a table using Angular Material that can be modified using Angular Drag & Drop.
Expected Behavior: Table should re-order on drag-drop
Current Behavior: Rows are draggable, and the order of the underlying data source changes, but when the row is dropped it snaps back to its original position in the table.
See this example:
https://stackblitz.com/edit/drag-drop-reorder-mattable
How can this be fixed/implemented?
(Also, I'm not sure why it's styled so poorly in Stackblitz. Any insight there would also be appreciated)
Edit: I found a super hacky way to get the rows to render again with the correct order, but there's no way this is the way it's expected to be implemented. I just put t.renderRows() to be executed after the drop event handler. See full line below
<mat-table #t
cdkDropList
(cdkDropListDropped)="onListDrop($event); t.renderRows()"
[dataSource]="dataSource"
class="mat-elevation-z8">
...
</mat-table>
EDIT 2: I've done a simple refactor to use rxjs, and the first drag-drop reorder for each element works great. But when I attempt to move an element that has already been moved once, I don't get the expected behavior. Stackblitz app has been updated.