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

Update pagination hook to account for changing data #5683

Merged
merged 3 commits into from Oct 13, 2021

Conversation

taysea
Copy link
Collaborator

@taysea taysea commented Oct 13, 2021

What does this PR do?

This PR makes adjustments to DataTable and usePagination hook to account for changing datasets that might occur from internal datatable changes such as search.

This ensures that the active page is never greater than the total number of available pages and that the pagination controls are showing based on the length of the adjustedData.

NOTE: Storybook example changed purely to allow for code review. Should be reverted before merging!

Where should the reviewer start?

src/js/utils/pagination.js

What testing has been done on this PR?

Tested with code example provided by #5652 (this is what is temp placed in the "Simple" DataTable story).

How should this be manually tested?

Follow steps outlined in "Steps to reproduce" in #5652 within the storybook example in this PR (Simple DataTable).

Any background context you want to provide?

What are the relevant issues?

Closes #5652

Screenshots (if appropriate)

Do the grommet docs need to be updated?

No.

Should this PR be mentioned in the release notes?

Yes. Fixed DataTable pagination bug regarding dynamic datasets.

Is this change backwards compatible or is it a breaking change?

Backwards compatible.

@ericsoderberghp
Copy link
Member

LGTM :)

Copy link
Collaborator

@MikeKingdom MikeKingdom left a comment

Choose a reason for hiding this comment

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

Looks good to me

Copy link
Collaborator

@halocline halocline left a comment

Choose a reason for hiding this comment

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

Logic looks good, just confirming the story change.

src/js/components/Pagination/stories/Simple.js Outdated Show resolved Hide resolved
@taysea taysea requested a review from halocline October 13, 2021 19:54
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.

DataTable pagination not updating correctly when data changes
4 participants