-
Notifications
You must be signed in to change notification settings - Fork 842
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
[EuiPagination] Added first
/last
buttons for compressed and allowing for indeterminate pageCount
#5362
Conversation
…rows’` option for `compressed`
…pdating the other `arrow` icons to a thicker weight
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 keeping this in draft because I want to add some guidelines based on this comment #4506 (comment) but the component work should be reviewable at this point.
const label = useEuiI18n( | ||
'euiPaginationButtonArrow.previousPage', | ||
({ page }) => `${toSentenceCase(type)} page${page ? `, ${page}` : ''}`, | ||
{ | ||
page: labelModifier, | ||
} | ||
); |
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 was trying to be clever here and interpolate the type
into the i18n, but I'm not sure this is going to work properly. I'm open to suggestions to fix.
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.
It probably makes the most sense to be verbose and have four distinct labels, one for each type. In any case the token name will need to be updated to match (euiPaginationButtonArrow.previousPage
is only correct sometimes)
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.
Yeah I just seem to constantly run into the "Hooks can be conditional" issue.
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.
Maybe do:
const labels = {
first: useEuiI18n(...),
previous: useEuiI18n(...),
next: useEuiI18n(...),
last: useEuiI18n(...)
}
const label = labels[type];
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.
Does it make sense to calculate those on every button mount when they'll each only use one?
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.
Well I did that method anyway, just for the type
part: 043654f
Preview documentation changes for this PR: https://eui.elastic.co/pr_5362/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5362/ |
…nation # Conflicts: # CHANGELOG.md # src/components/icon/__snapshots__/icon.test.tsx.snap
I've decided to push off the Guidelines to a follow up PR because it may require some work to the EuiTablePagination component as well. So I'm opening this PR up for review now. |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5362/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5362/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5362/ |
This makes sense, but is this the intended result if you continue changing the pagination?
|
I had thought about that too, but honestly, I think it's better to indicate something about their current state in the pagination than nothing. |
Woot! I've pushed the final SR-only wrapper. Can you take one last look once that builds to make sure it all still gets read out properly? It also adds that |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5362/ |
@cchaos it's looking good! I found just a few small issues in Firefox (94.0.2) and I have one design suggestion. I tested in Chrome, Safari, Edge, and Firefox. Firefox issuesFocus rings now is being cut in Firefox. The hover styles are not taking effect in Firefox. First and last page iconI did a quick research on other pagination components and most of them are using a similar icon to the ones you added: |
Thanks @miukimiu . I'm working on those Firefox fixes. In general, first/last buttons aren't great but it's the only way to quickly get to the first page when there isn't numbering. I also agree that in isolation, the icon that you showed is more representative of going to the beginning/end. The problem I see with them is that they harder to distinguish between themselves and the single arrow previous/next icons. If you'd like to continue exploring options for the icon, I'm happy to wait to finalize this PR next week. |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5362/ |
// The compressed version already should the activePage with pageCount, so it just needs `Page` | ||
// The other types will append the whole string with total pageCount or `collection` | ||
const accessiblePageCount = compressed | ||
? pageLabel |
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 compressed
true statement renders "Page" in the compressed SR-only block. Could we add a dynamic element like activePage + 1
so screen readers pick up the change and announce a page number?
This is my only additional comment. The code is working really well in VO and I was able to traverse each pagination example easily and clearly.
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.
Would that not duplicate the active page number and make the readout "Page 1, 1 of 5"?
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.
Reading my comment again, I don't think I was as clear as I'd hoped.
The compressed accessiblePageCount
text is just "Page" right now. For consistency, I'd like to make it render "Page 1 of 5". We should be able to pull that off with string interpolation like you're using in other SR-only blocks.
! pagination.tsx#289
const pageLabel = useEuiI18n('euiPagination.page', '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 mostly understood what you meant. But I'm wondering if that will duplicate what the screen-reader reads out since the actual visible text is 1 of 5
but the screen-reader-only text would be Page 1 of 5
. So would it not then read both? So you'd hear "Page 1 of 5. 1 of 5"?
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.
Okay, I'm following you now. Yes and no. The visual text would be a repeat, but that change wouldn't be announced when users press Next, Previous, First, or Last buttons. Screen reader users will just hear the SR-only live region we're adding until they arrow through the visual text. If they're moving by TAB or other shortcut keys, they may never settle on the visual text. It could feel a little heavy, but I'm inclined to err on the side of redundancy over brevity in this case.
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.
Ok gotcha, I'll just remove the compressed specific logic and have it read out the same as all the others.
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.
Great work! I had just one comment about the compressed view's SR-only message, and I'm ready to approve.
@cchaos I agree with this and I prefer having more context. But just noticed that now in mobile the pagination is taking too much space. Is there anything we can do to reduce the size? Maybe in mobile instead of saying "Rows per page" just "Rows"? |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5362/ |
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.
👍 LGTM!
Thanks @1Copenut and @miukimiu !!! I've pushed the new icons: As for the mobile issues with the table pagination that contains the |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5362/ |
I'd love to get a final eng check on this PR before I merge 🙏 |
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.
Code changes LGTM!
Merging! Thanks everyone for the reviews 💟 |
Don't look at the commit summaries, they're inaccurate with the end result 😆
This one got away from me a bit, which meant doing a bit of refactor of the component itself. I'll highlight the actual changes:
Added "First page" and "Last page" arrow buttons when
compressed=true
I also removed the click handlers the numbers completely to just rely on the arrow buttons for navigation and the numbers for indicating current page.
Screen.Recording.2021-11-08.at.06.41.03.PM.mp4
This also fixes the situation where users could never get back to the first page easily because the "first / 1" button was replaced with the current page.
Before
Screen.Recording.2021-11-08.at.06.42.07.PM.mp4
Added
responsive
prop that changes the mobile view tocompressed
and is customizableBefore, the simplicity in mobile views was ok, but I think it lacked context. So I removed the custom Sass mixins and just created a
responsive
prop (with the same breakpoints as before) and forced to thecompressed
view ifresponsive
is anything but `false.Handle situation where
pageCount=0
as indeterminateFixes #4506
This meant generally hiding all the numbered buttons and relying solely on the arrow buttons to navigate. In order to simplify the
activePage
count, I determined that negative indexes start from the end. So whenpageCount=0
and the user clicks the "Last page" button, it will return-1
.Screen.Recording.2021-11-08.at.06.37.14.PM.mp4
Added
doubleArrowLeft
,doubleArrowRight
,arrowStart
,arrowEnd
to EuiIconThese didn't exist yet in order to create the first/last buttons. I also updated the regular arrow versions to the slightly fatter version we've been using in Figma.
Update: I replaced the double arrows below with the new ones above, but kept the double arrows in for any future use cases.
Checklist
[ ] Checked for breaking changes and labeled appropriately