Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix pagination effects - for client tables, use filteredItems instead of items length for totalItemCount #1625

Merged
merged 2 commits into from
Dec 15, 2023

Conversation

mturley
Copy link
Collaborator

@mturley mturley commented Dec 14, 2023

Made the same fix in the new react-table-batteries code as well. Note to self: Perhaps we should rename the totalItemCount to filteredItemCount in the new version, since it really should be the count of all items just before pagination (after filtering), not the total number of items in the unfiltered collection.

For client-side tables, the totalItemCount is derived internally inside getLocalTableControlDerivedState, and it was incorrectly using items.length. Changing that to filteredItems.length makes the logic in usePaginationEffects behave as intended, which means if the user ends up on an invalid pagination page (e.g. they are on page 2 and they apply a filter that has results on one page), it will kick them back to the last valid page.

cc @ibolton336

… of items length for totalItemCount -- maybe should rename that

Signed-off-by: Mike Turley <mike.turley@alum.cs.umass.edu>
Copy link
Member

@sjd78 sjd78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on the same table that wasn't working before and it work now! 😄

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants