F
Filament7mo ago
nowak

Duplicate and missing records/rows when navigating table pages

I was looking for a record in an "Orders" table, that I new existed, and I wasn't able to find it while navigating the 10 record per page table pages. I then set the table to show all records, which revealed the record I was looking for. Also, when navigating between pages, I see the same records on different pages (see screen recording) When setting a filter for the order date, for some reason, the record shows on page 2 when navigating the table pages, and the same records don't appear on different pages. Does anyone know why this is?
9 Replies
martin-ro
martin-ro4w ago
@nowak I'm seeing that exact same issue too. Did you figure it out?
nowak
nowakOP4w ago
No I did not, but please let me know if you find an answer for this
LeandroFerreira
difficult to assist you without code. Maybe you could create a minimal repo on github to reproduce this issue
nowak
nowakOP4w ago
I am not sure exactly how to reproduce it exactly yet, as I remember it being a bit random. @martin-ro is your use case easy to reproduce?
martin-ro
martin-ro4w ago
Yes, meanwhile I have figured it out. The minimal reproducible setup would be a table with ->defaultSort('created_at', 'desc') or a TextColumn::make('created_at')->sortable() with records that have identical created_at timestamps. The way to solve that for me was:
public static function table(Table $table): Table
{
return $table
->defaultSort('created_at', 'desc')
->defaultSort('id', 'desc')
...
public static function table(Table $table): Table
{
return $table
->defaultSort('created_at', 'desc')
->defaultSort('id', 'desc')
...
The second defaultSort fixed it for me @nowak This also works:
TextColumn::make('created_at')
->sortable(['created_at', 'id'])
TextColumn::make('created_at')
->sortable(['created_at', 'id'])
nowak
nowakOP4w ago
Wow. Good catch @martin-ro! @Leandro Ferreira I am not able to test this out and create a minimal repo on github any time soon, but if no one has made an issue on github about this before I have more time available, I will do it then.
martin-ro
martin-ro4w ago
Yes, a GH issue with the fix would be a good start so the problem gets visible/searchable for others.
nowak
nowakOP4w ago
I see this more as a workaround than a fix. Records should not be missing in tables and the same record should not be shown on multiple table pages in the first place
martin-ro
martin-ro4w ago
yeah, that's a better description. The default is certainly not expected behaviour, so it's a bug.

Did you find this page helpful?