-
Notifications
You must be signed in to change notification settings - Fork 839
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
[Data Grid] Add hidePerPageOptions prop into EuiDataGridPaginationProps #3700
[Data Grid] Add hidePerPageOptions prop into EuiDataGridPaginationProps #3700
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
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.
Instead of a new prop for this, I feel making pageSizeOptions
optional and/or checking for an empty array is a better approach.
Yup, I think that's okay. Our existing component pagination prop types are all largely different between inmemorytable, basictable, tablepagination, and pagination. Not much unity to maintain between them, and supporting an empty pageSizeOptions is probably the better path forward. |
@@ -218,10 +218,13 @@ function renderPagination(props: EuiDataGridProps, controls: string) { | |||
} = pagination; | |||
const pageCount = Math.ceil(props.rowCount / pageSize); | |||
|
|||
if (props.rowCount < pageSizeOptions[0]) { | |||
if (pageCount <= 1) { |
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.
The reason this was previously props.rowCount < pageSizeOptions[0]
is to keep the pagination controls around when switching to a large page size. For example, if there are 30 results and the page options are 5, 25, 50
, switching the page size to 50
will cause the controls to disappear.
Maybe, if (props.rowCount < (pageSizeOptions[0] || pageSize)) {
instead? Then it uses the active page size if there are no options.
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 explanation, I didn't think about it at the first sight!
My only concern is: who guarantees the pageSizeOptions
will be in ascending order?
An user can pass it like [100, 50, 25]
, right?
So I also placed a sorting function to be sure.
…ion_hide_per_page # Conflicts: # CHANGELOG.md
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.
One more request :)
…ion_hide_per_page # Conflicts: # CHANGELOG.md
jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3700/ |
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.
Changes LGTM; Pulled & tested existing, empty, and non-existent pageSizeOptions
locally. Also tested the logic in displaying page sizes selection when items < the smallest option.
Summary
Add
hidePerPageOption
s prop intoEuiDataGridPaginationProps
forEuiDataGrid
pagination prop:In kibana
Data table
visualization theRows per page
is controlled by vis options tab, so it needs a possibility to hide choosing rows per page.Checklist