Rebuild-Black-Business / RBB-Website

Website to help connect black-owned businesses with consumers and resources
https://www.rebuildblackbusiness.com/
MIT License
118 stars 72 forks source link

Fix/pagination focus hits two elements #255

Closed adxmantium closed 4 years ago

adxmantium commented 4 years ago

Describe your PR

In #245 I fixed some pagination hover/focus styling issues, but there was some apparent tabbing issues (as noted by reviewers 🙏 ). Basically, it takes two tab presses in order to get to the next/prev pagination link - it should only take one, which is what this PR addresses.

As @magnificode mentions, this is caused by the Button component (<button>) being wrapped in an Link component (<a>) and both of these elements are naturally tabbable elements, so the fix was to remove one of them - or better yet - combine them! 😮 Was able to maintain the Button styles, and turn it into a clickable link by setting it as={Link} and removing the <Link> component. I made this change for the pagination links and the pagination arrows as well.

While I was in here, I fixed up two minor things as well related to pagination:

  1. In the dev tools console, there was an error regarding isDisabled is a required prop in PaginationArrow, but it didn't look like that prop was being used at all, so I removed it from propTypes so that it didn't continue to yell about it being required.
  2. The getPageLink func was returning a url with a ? even if there were no params (like when page=1) bc getUpdatedSearchParams returns an empty string when page=1. So I just added a condition to only return the url with ? if it has param.

Related to Trello ticket # https://trello.com/c/NkrJyrQ2/206-pagination-focus-hits-two-elements

Pages/Interfaces that will change

Affects tabbing on Pagination links Before: it took two tab presses to nav to the next pagination link After: it will take one tab press to nav to next pagination link

Screenshots / video of changes

pic of what screen readers pic up (via firefox) vid of tabbing once to nav from link to link
https://share.getcloudapp.com/Wnubb5Kj https://share.getcloudapp.com/E0uzzNKX
pagination link for page=1 (before) pagination link for page=1 (after)
https://share.getcloudapp.com/rRulldbJ https://share.getcloudapp.com/2Nu55QlZ

Steps to test

  1. go to /businesses
  2. click on a pagination page link
  3. scroll back down to pagination component and start tabbing - should only only take one tab press now to move to the next link

Additional Notes

netlify[bot] commented 4 years ago

Deploy request for rebuild-black-business accepted.

Accepted with commit cad5b98c0b3abb818c793355a4ba36666371e0a5

https://app.netlify.com/sites/rebuild-black-business/deploys/5ee99d283e00e800074a6a5b

racedale commented 4 years ago

@all-contributors please add ajadams for code

allcontributors[bot] commented 4 years ago

@racedale

I've put up a pull request to add @ajadams! :tada: