primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Updating sorted data causes shuffle behavior

Open caseylutz opened this issue 10 years ago • 8 comments

I've written up a plnkr here showcasing the issue.

https://plnkr.co/edit/thxW3u?p=preview

Steps to reproduce are as follows:

  1. Bind a data set with a field that won't change often between cycles
  2. Sort by the field (in this case, sort by Class, it doesn't change much)
  3. Initiate a change to the data (in this plunkr, click The Button)
  4. Now cause an event cycle (move your mouse over the table or something)

Long and short of it is that the data rows in the dataTable will all start to "jumble" around.

caseylutz avatar May 23 '16 20:05 caseylutz

Any update on this bug? Is it likely to make it into Beta 9?

GraemeSMiller avatar Jun 28 '16 17:06 GraemeSMiller

I've replicated and added a fix that seems to prevent resort which is main cause of shuffle.

cagataycivici avatar Jun 28 '16 20:06 cagataycivici

Ok - so does that mean it now no longer re-sorts correctly if the underlying data changes?

E.g. Apply sort by date, change a date value and it won't be sorted until you manually re-apply sort on data column?

GraemeSMiller avatar Jun 28 '16 20:06 GraemeSMiller

No, it should still sort when underlying data changes, but only once, with this bug it was sorting even on mouseover :)

cagataycivici avatar Jun 30 '16 07:06 cagataycivici

Great Thanks for that - it is a really nice feature to have.

GraemeSMiller avatar Jun 30 '16 16:06 GraemeSMiller

This appears to be happening in 4.1.3 and 4.2.1

mikedunham avatar Sep 29 '17 18:09 mikedunham

This issue is still present in 4.3.0

LuminalZero avatar Feb 19 '18 20:02 LuminalZero

For anyone still running into this... In my case, this bug presented itself via a DataTable that had the immutable property set to false. After sorting the DataTable and then altering one of the records, the shuffling behavior appeared while moving the mouse (i.e. during change detection cycles). I was able to fix my particular problem by making a ViewChild of the DataTable, and then setting the preventSortPropagation property of the DataTable to true after altering the record.

export class MyComponent {
  @ViewChild('dt') dt: DataTable;

  updateRecord() {
    // call to my service to update my record
    this.dt.preventSortPropagation = true;
  }
}

LuminalZero avatar Feb 21 '18 19:02 LuminalZero