Skip to content
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: add pagination nav component #6199

Merged
merged 24 commits into from
Jul 10, 2020

Conversation

janhassel
Copy link
Member

@janhassel janhassel commented Jun 4, 2020

React implementation of PaginationNav component. https://the-carbon-components.netlify.app/?nav=pagination-nav

@joshblack We talked about this one a while ago, especially the dynamic behaviour of the overflow. I opened this as a draft PR so we can get a discussion started on what you guys need from us for this contribution.


This PR comes with two UX teaks in comparison to the current vanilla component.

  1. It adds a "loop" prop (disabled by default) that allows users to cycle through all pages when they reach the end / start.
  • Screen Recording 2020-06-10 at 17 34 52
  1. The behaviour of how the overflow is treated and presented to the user changes. Instead of overlaying the overflow with a page indicator, the component always keeps the current page visible and out of the overflow (see screen recordings attached)
  • Current behaviour: Screen Recording 2020-06-10 at 17 38 52
  • Proposed behaviour: Screen Recording 2020-06-10 at 17 40 32

@netlify
Copy link

netlify bot commented Jun 4, 2020

Deploy preview for carbon-elements ready!

Built with commit 0b80936

https://deploy-preview-6199--carbon-elements.netlify.app

@netlify
Copy link

netlify bot commented Jun 4, 2020

Deploy preview for carbon-components-react ready!

Built without sensitive environment variables with commit 0b80936

https://deploy-preview-6199--carbon-components-react.netlify.app

@emyarod
Copy link
Member

emyarod commented Jun 4, 2020

I've had this completed for almost 9 months now, including the overflow behavior but since it was deprioritized, all I have left is the test suite. if we're ready to bring this into the library I can just round out the test suite and open a PR

@joshblack
Copy link
Contributor

@aagonzales gave it a look and really liked the changes! I think we could bring in the UX changes along with the code formatting stuff mentioned above (along with style guide stuff). Feel free to use any of the existing work too and we can definitely help ya out 😄

If you have any questions about tests btw, just let me know!

@janhassel
Copy link
Member Author

@joshblack Thanks for the feedback (and the addition of translateWithId in the styleguide). I refactored the component accordingly. Would you mind taking another look and if there are only minor things left, I can work on the test suite.

@janhassel janhassel requested a review from joshblack June 15, 2020 14:44
Copy link
Contributor

@joshblack joshblack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great! 🎉 Just had a couple of questions:

  • What should the responsive behavior be like for this component?
  • Do we need to flag the current page with aria-current="page"?

For determining cuts, it seems like it works great at the midpoint but when hitting past that it seems to make what is clicked jump to the edge before the overflow:

demo

Would it make sense to have that midpoint behavior happen throughout the range of pages?

<select
className={`${prefix}--pagination-nav__page ${prefix}--pagination-nav__page--select`}
aria-label={`Select ${t('carbon.pagination-nav.item')} number`}
onChange={e => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be using onBlur here per the jsx-a11y rule?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue with onBlur is that it only triggers once the user clicks on another element or continues with tab

Screen Recording 2020-06-19 at 17 41 58

@janhassel
Copy link
Member Author

janhassel commented Jun 19, 2020

@joshblack

  • I updated (and actually simplified) the overflow behaviour to feel more natural. Since I haven't worked with hooks very much I'd really appreciate your input on my implementation there since I suppressed the warnings from React about the dependency array and I'm not sure if there is another way for the functionality here.
    • Screen Recording 2020-06-19 at 17 34 14
  • Regarding aria-current="page": good point! Missed that, thanks!
  • For the responsive behaviour our team is planning to always maximize it to width available. The exact calculation would probably depend on the product though. So passing in the maximum amount of pages to props.itemsShown would be my proposal. Btw, the component enforces a minimum of 4 shown items. Together with the two buttons that's 288px (6*48) width which fits perfectly in the smallest screen size supported (288px component + $spacing-05 left and $spacing-05 right = 320px)
    • Screen Recording 2020-06-19 at 17 48 57

@janhassel janhassel marked this pull request as ready for review June 26, 2020 12:00
@janhassel janhassel requested a review from a team as a code owner June 26, 2020 12:00
@ghost ghost requested review from aledavila and dakahn June 26, 2020 12:00
@joshblack
Copy link
Contributor

Hey @janhassel! 👋 So glad that this got moved from draft -> ready for review 🎉

I wanted to ask you if you had an open slot sometime this week for us to go over the PR on a call? Thought it might be helpful for all of us and hopefully speed up the process of getting things merged in 😄 This really would only be talking through the component, its intended behaviors, any relevant implementation details you think are worth sharing, etc. Totally understand if not! Just wanted to reach out and see.

@janhassel
Copy link
Member Author

@joshblack Definitely! I sent you an invite for tomorrow morning, feel free to counter if you prefer a different time slot 🙂

Copy link
Contributor

@aledavila aledavila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome work. So far it looks good

Good to go:
MacOS: Chrome, Firefox, and Safari. No DAP violations. Keyboard navigation works.

Issues on VO:
Safari:
When selecting a page it doesn't announce if I have selected it. If I am navigating via arrows it does not read which page I am highlighting.

Copy link
Contributor

@dakahn dakahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a few things testing with JAWS 2020 and NVDA on Firefox latest in Windows 10:

  • the active button has no focus state
  • the current active page button is described as "unavailable" -- which makes sense technically, but sounds quite confusing
  • when the user selects a page the button's label should be updated to 'active'
  • the next page button when activated doesn't announce the changes (updated page from previous page)

@janhassel
Copy link
Member Author

Thanks for the feedback!

@aledavila

  • Should be fixed now

@dakahn

  • it's in now but it doesn't look too good due to the blue underline. Maybe @aagonzales can give some visual guidance here?
    • image
  • This is an interesting one as I couldn't provoke a similar behaviour on VO (the only machine with Windows and JAWS installed is in the office, so I currently don't have access to that one). Is this how JAWS usually describes a disabled button (similar to "dimmed" on VO) or what could cause that?
  • I updated the label. Let me know if it is better now
  • Should be fixed

I'm currently facing the problem that the live region "Page 5 of 10" is read twice and after some poking around it seems that the component is rendering twice when a button is clicked. However, I cannot see this in the React DevTools Profiler.
Do you guys have any idea what could be causing this (or is it maybe only an issue with my setup)?

@aagonzales
Copy link
Member

Hi @janhassel ! I talked to Jeannie about the selected+focus state overlap and she says its fine. We agree it does look not the best but we can live with it since its a temporary state and follows the correct styles.

Copy link
Contributor

@aledavila aledavila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates! LGTM pending @dakahn changes

@dakahn
Copy link
Contributor

dakahn commented Jul 8, 2020

We're reading button updates now with NVDA which is great. When the 'next page button' is activated you just here '5', '6' ,'7' etc maybe something more clear might be, "page 5, active", but this isn't a blocker.

Unavailable is what's read by JAWS and NVDA in place of dimmed -- it's not a blocker technically since it's correct.

JAWS 2020 still isn't reading the page updates when the 'next page button' is activated. Let me see if I can get this working for you since I can test on JAWS here on my machine

Copy link
Contributor

@dakahn dakahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're actually good to go here. JAWS is reading aria-live updates just fine. (fun fact, JAWS will not read aria-live updates unless it is started and running before opening Firefox -- I'm talking to you, future me)

@janhassel
Copy link
Member Author

@dakahn That's good to know actually, might save me a lot of time debugging once I have access to the JAWS machine again 😀

I added aria-atomic to the live region which should cause JAWS to read out the full status now ("Page 5 of 10") instead of just the number. I didn't notice a difference on Chrome or Safari with VO, hence I didn't include it earlier. Can you give it a try and see if it's as expected now?

@kodiakhq kodiakhq bot merged commit 007b1e6 into carbon-design-system:master Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants