EuiDataGrid: fixed Rows per page controls disappear when there's only a single page#2978
EuiDataGrid: fixed Rows per page controls disappear when there's only a single page#2978snide merged 7 commits intoelastic:masterfrom
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? |
|
@cchaos it was just a minor logical error in the |
|
Jenkins, test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_2978/ |
|
Thanks @anishagg17, this does fix part of the issue described in #2972 (but only for that one example). Could you update the rest of the examples to behave the same? Unless, @chandlerprall, you think there's a way for EuiDataGrid to handle this directly? The other half of the issue is that EuiDataGrid, hides all pagination controls when there's only a single page. Meaning, once I've decided to display all 100 results per page, I can't get back to displaying only 25 per page. |
|
I too noticed that issue and will soon fix that issue too. |
Yep, the problematic logic is at eui/src/components/datagrid/data_grid.tsx Line 202 in 9bc89c0 |
…are less than current number of rows to datagrid
|
@cchaos now both issues are fixed , you may have a look . @chandlerprall Don't you think users should have complete flexibility of their own and should reset pageIndex according to their need |
|
Jenkins, test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_2978/ |
chandlerprall
left a comment
There was a problem hiding this comment.
Don't you think users should have complete flexibility of their own and should reset pageIndex according to their need
EuiDataGrid was built with that being the intention - the application can decide whether or not to reset the current page. Best practice is to reset (so thank you for updating the examples to act that way), but we've had the opposite functionality requested (or at least brought up) around EUIs tables, so the option is left to the application. So, long answer short, yes.
|
|
||
| if (pageCount === 1) { | ||
| return null; | ||
| newPageSizeOptions = []; |
There was a problem hiding this comment.
I don't think we want to modify the page size options, for a few reasons:
- the data may be filtered outside the grid, e.g. there's a search box on the page that is used to load new data; data sets of different sizes would change the availability of page sizes
- this logic almost enforces pagination, as it keeps the page size under the total number of pages
- an extension of the previous point, this artificial limiting would only apply once the
pageCountis 1, meaning the available sizes could change after the user interacts with the original set of page sizes
There was a problem hiding this comment.
@chandlerprall should I just return the normal pagination if the page count is 1 also
|
@chandlerprall I noticed in my application that in |
| const pageCount = Math.ceil(props.rowCount / pageSize); | ||
|
|
||
| if (pageCount === 1) { | ||
| if (props.rowCount === 0) { |
There was a problem hiding this comment.
I have removed pagination only if there is no content to render
|
jenkins test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_2978/ |
chandlerprall
left a comment
There was a problem hiding this comment.
Changes LGTM; Pulled & tested locally.
@cchaos are you good with the idea of always showing pagination except when the grid is told there are 0 rows of content?
|
Hey @anishagg17 , @chandlerprall & @snide & I talked around this a bit and decided that the best experience for data grid users would be to only show the pagination controls IF the length of the data (total number of rows) is less than the lowest number of rows per page. For example, since Then the pagination controls will hide if the table contains less than Can you update the logic to support this? |
…to minimum page size
|
@cchaos Done ! |
|
Jenkins, test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_2978/ |
cchaos
left a comment
There was a problem hiding this comment.
Great, I think this works well! Just cleaned up the changelog language a bit
Co-Authored-By: Caroline Horn <549577+cchaos@users.noreply.github.com>
|
Thanks for the PR! |
|
Thanks for merging @snide |


Summary
Fixes : #2972
fixed Rows per page controls disappear when there's only a single page
Checklist