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
feat(Pagination): automate pagination and overflow logic #3182
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. Can you update the title of the PR to be more descriptive please. Thanks!
PatternFly-React preview: https://patternfly-react-pr-3182.surge.sh |
Codecov Report
@@ Coverage Diff @@
## master #3182 +/- ##
==========================================
- Coverage 67.52% 67.52% -0.01%
==========================================
Files 896 896
Lines 25112 25133 +21
Branches 2173 2178 +5
==========================================
+ Hits 16958 16971 +13
- Misses 7141 7147 +6
- Partials 1013 1015 +2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are these utils used with the pagination component?
I'm also curious how does this solve #1567 (e.g., using an offset). There is no example showing usage?
Ideally, the pagination component would be able to figure out what page you're on based on the total available rows and number of items per page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few questions/comments, looking good. On first pass, it seems to improve the intro-table tutorial quite a bit - excited to get this in!
packages/patternfly-4/react-core/src/components/Pagination/PaginationOptionsMenu.tsx
Outdated
Show resolved
Hide resolved
packages/patternfly-4/react-core/src/components/Pagination/Navigation.tsx
Outdated
Show resolved
Hide resolved
packages/patternfly-4/react-core/src/components/Pagination/Pagination.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/patternfly-4/react-core/src/components/Pagination/Pagination.tsx
Outdated
Show resolved
Hide resolved
): void { | ||
if (event.keyCode === KEY_CODES.ENTER) { | ||
const inputPage = Navigation.parseInteger(this.state.userInputPage, lastPage) as number; | ||
onPageInput(event, Number.isNaN(inputPage) ? (page as number) : inputPage); | ||
onSetPage(event, Number.isNaN(inputPage) ? (page as number) : inputPage); | ||
this.handleNewPage(event, Number.isNaN(inputPage) ? (page as number) : inputPage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there's a better way of handling that page
here could be a string or a number. Could we instead cast it to a number in the place where it returns a string so we can avoid having to use as number
type assertion in so many places? No worries if not, just curious in case it's an easy improvement.
…and onPerPageSelect
…d handle pagination overflow. Fix for patternfly#3136
… handle pagination overflow. Fix for patternfly#3136
…o Navigation and PaginationOptionsMenu. onSetPage and onPerPageSelect now return 5 values each for use in automating pagination
…uilt out new Demo to show functionality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Nice job
@@ -69,6 +85,8 @@ export interface PaginationProps extends React.HTMLProps<HTMLDivElement> { | |||
perPage?: number; | |||
/** Select from options to number of items per page. */ | |||
perPageOptions?: PerPageOptions[]; | |||
/** Indicate whether to show last full page of results when user selects perPage value greater than remaining rows */ | |||
defaultToFullPage?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious if defaultToFullPage
is a PatternFly pattern in core? If not, lets double check this behavior with a designer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for calling this out @dlabrecq , doing this now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice work!
…tch new last page of results when page number is automatically updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😁👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @evwilkin Thanks for adding the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it! Nice work @evwilkin!
Your changes have been released in:
Thanks for your contribution! 🎉 |
What:
fixes #3136
This feature allows the component to automatically paginate the users's data for them, and provides a "defaultToFullPage" flag that will automatically move the user back to the last full page of results when they change the number of rows to view per page.
Additional issues: