-
Notifications
You must be signed in to change notification settings - Fork 844
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
Hide paginationBar in EuiBasicTable when there is no data #2598
Conversation
df1868e
to
243a566
Compare
Let's hold off on merging this until #2428 (tables conversion to typescript) is in. This should be able to drop into the new pagination_bar.tsx file without issues, but would like to avoid any potential merge conflicts especially as the TypeScript PR is a community contribution. edit: Note: git understood the conversion of pagination_bar.js -> pagination_bar.tsx as a rename of the file, so I would expect a rebase or merge of master for this PR to automatically adjust to the changes without a conflict. |
I wonder about the efficacy of this decision. I can envision scenarios where a hidden pagination bar would confuse a user who believes there is more data and that a bug is preventing access, rather than communicating that there is only one table worth of data. If we do decide this is the right thing to do, I would question if this logic should be in the pagination bar or in any consuming locations (i.e. check the row count against the minimum page size in the table code instead of the pagination bar), as that allows the pagination bar to be used/displayed in any situation where we (or a consuming dev) wants to show a pagination bar with only one page. @cchaos thoughts? Mostly I want to make sure these questions were/are thought about - I'm fine being wrong as long as the discussion happen(s/ed)! |
@chandlerprall You bring up a valid point. I spent yesterday going back and forth between hiding the pagination or not in this scenario and see arguments for either direction. However, I just checked a reference that I like (Mint) and they keep the "rows per page" UI element even when there's no enough rows of data. See: In what cases does the number of rows change? I can think of a) search b) filters, and in this new implementation we would be hiding the pagination which as you said could be confusing. |
@andreadelrio It would also be helpful to evaluate this decision with screenshots. Otherwise I have to manipulate the example codes in order to view the scenarios. I am also confused when we talk about pagination vs rows per page. I feel these are either two separate UI's or Pagination encompasses the actual EuiPagination component and the rows per page. Can you clarify those distinctions? Thinking about it generally, I would assume:
In any case, we will also eventually need some sort of caption explaining how many total results #1237. |
@cchaos So far I’ve been using "Pagination" to refer to To make sure we're all on the same page, this would look like this (again, this is what we were already doing) |
For user experience, I would prefer showing e.g. |
Screenshots are helpful. Thanks! I think that the |
I think that Also, the caption that we will eventually add (#1237) could help make things even more clear for this particular case (# rows = chosen # of rows per page). |
@chandlerprall It sounds like you just don't agree with this ticket #899 to begin with? The only problem with
I actually think that is more confusing. The number of rows selector should not change (just like in your Mint example). It would be more indicative if you have only 3 rows and the selector says "10 rows per page" that you only have 3 results. Otherwise, I could possibly think there are more pages of 3 rows since I'm only seeing that same amount. I think we've beaten this over the head too much. I would say that we should:
|
I think there might have been a misunderstanding, I wasn't suggesting the number of rows selector should change. I agree with the behaviour you're describing. |
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 deleted my previous comment since I was a dummy and was looking at the published site.
The only scenario that still seems to be off is when searching in EuiMemoryTable and there are 0 results, I'd think we'd still want the whole pagination bar. But the empty message helps to convey that there aren't any results so is it necessary?
Other than that, just had some code cleanup comments.
CHANGELOG.md
Outdated
- Hide `paginationBar` in `EuiBasicTable` when there is no data ([#2598](https://github.com/elastic/eui/pull/#2598)) | ||
- Display `EuiPagination` in `EuiBasicTable` when there is only 1 page ([#2598](https://github.com/elastic/eui/pull/#2598)) |
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.
These entries can be rolled into one because they both are affecting EuiBasicTable pagination options
@@ -384,7 +384,7 @@ export class EuiBasicTable extends Component { | |||
); | |||
|
|||
const table = this.renderTable(); | |||
const paginationBar = this.renderPaginationBar(); | |||
const paginationBar = this.renderPaginationBar(items); |
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.
A better thing to pass here would be the length of items so that there's an understanding of what the renderPaginationBar()
method is doing with that parameter which is just checking that items to do exist.
const paginationBar = this.renderPaginationBar(items); | |
const paginationBar = this.renderPaginationBar(items.length); |
@@ -1049,9 +1049,9 @@ export class EuiBasicTable extends Component { | |||
return profile.align; | |||
} | |||
|
|||
renderPaginationBar() { | |||
renderPaginationBar(items) { |
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.
Then here, you can change the name to something like
renderPaginationBar(items) { | |
renderPaginationBar(numItems) { |
@@ -173,7 +173,7 @@ export const EuiPagination: FunctionComponent<Props> = ({ | |||
</EuiI18n> | |||
); | |||
|
|||
if (pages.length > 1) { | |||
if (pages.length > 0) { |
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.
pages.length
will never be less than 0 so this statement will always return true
, which means that it's an unnecessary check the component should always return the full pagination and never an empty span.
I'm happy with the direction this is going. I'll remove myself from the rest of the conversation, but do a final technical pass when the functionality is stable. |
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'm good with that decision (leaving pagination off if 0
results). LGTM!
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 locally
Need to update &commit jest's snapshots for this to pass CI - yarn test-unit -u
jenkins test this |
Summary
This PR introduces two changes in
EuiBasicTable
:pageSizeOptions
. For example:pageSizeOptions = [3, 5, 8]
totalItemCount > 3
-> Display pagination? YestotalItemCount <= 3
-> Display pagination? NoFixes #899
Checklist
- [ ] Checked in dark mode- [ ] Checked in mobile- [ ] Checked in IE11 and Firefox- [ ] Props have proper autodocs- [ ] Added documentation examples- [ ] Checked for breaking changes and labeled appropriately- [ ] Checked for accessibility including keyboard-only and screenreader modes