Skip to content

UnderlineNav2: Add aria-hidden and sr-only class support for descriptive counters - #2551

Merged
broccolinisoup merged 8 commits into
mainfrom
broccolinisoup/UnderlineNav-sign-off-remediations-2
Nov 10, 2022
Merged

UnderlineNav2: Add aria-hidden and sr-only class support for descriptive counters#2551
broccolinisoup merged 8 commits into
mainfrom
broccolinisoup/UnderlineNav-sign-off-remediations-2

Conversation

@broccolinisoup

@broccolinisoupbroccolinisoup commented Nov 8, 2022

Copy link
Copy Markdown
Member

Addressing an accessibility sign-off review issue that described below.

The span wrapping the counter value is adjoined to the link text for screen reader users, creating accessible names like: "Issues12". The current span should be hidden from screen reader users with aria-hidden="true", and an alternative created with class="sr-only" (or relevant off-screen/screen-reader-only class) that recreates exactly the same value but with some separation and parentheses

<span aria-hidden="true" class="CounterLabel-sc-13ceqbg-0 ikCrlz">12</span>
<span class="sr-only">&nbsp;(12)</span>

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@changeset-bot

changeset-botBot commented Nov 8, 2022

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1c87674

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
@primer/reactPatch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actionsBot commented Nov 8, 2022

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
dist/browser.esm.js78.89 KB (0%)
dist/browser.umd.js79.54 KB (0%)

@broccolinisoup
broccolinisoup temporarily deployed to github-pages November 8, 2022 03:35 Inactive
@broccolinisoupbroccolinisoup changed the title UnderlineNav2: aria-hidden for visible counters and sr-only equivalent for screen readersUnderlineNav2: Add aria-hidden and sr-only class support for descriptive countersNov 8, 2022
@broccolinisoup
broccolinisoup temporarily deployed to github-pages November 8, 2022 03:44 Inactive
@broccolinisoup
broccolinisoup marked this pull request as ready for review November 8, 2022 04:38
@broccolinisoup
broccolinisoup requested review from a team and josepmartinsNovember 8, 2022 04:38
@broccolinisoup
broccolinisoup temporarily deployed to github-pages November 8, 2022 04:43 Inactive
@josepmartins
josepmartins temporarily deployed to github-pages November 8, 2022 08:35 Inactive

@josepmartinsjosepmartins left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! ✨

Just a couple of non-blocking comments

Comment threadsrc/UnderlineNav2/UnderlineNav.tsx Outdated
{loadingCounters ? (
<LoadingCounter />
<Box as="span" data-component="counter">
<LoadingCounter />

@josepmartinsjosepmartinsNov 8, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

non-blocking and asking out of ignorance: Is it necessary to add a span/wrapper to the LoadingCounter or should be hidden from screen readers? 🤔

cc @ericwbailey

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

That wasn't an intentional change, sorry! Thanks for pointing this out.

<Box as="span" data-component="counter" sx={counterStyles}>
<CounterLabel>{counter}</CounterLabel>
<CounterLabel aria-hidden="true">{counter}</CounterLabel>
<VisuallyHidden>&nbsp;({counter})</VisuallyHidden>

@josepmartinsjosepmartinsNov 8, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

non-blocking: Maybe it's just relative to the UnderlineNav, but I wonder if we should consider adding this extra wrapping markup + the VisuallyHidden behavior inside the Counter component.

@broccolinisoupbroccolinisoupNov 9, 2022

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I am not really sure if I can follow you, sorry!

Do you mean like this

<CounterLabel sx={counterStyles}>
<Box as="span" data-component="counter" aria-hidden="true">
{counter}
</Box>
<VisuallyHidden>&nbsp;({counter})</VisuallyHidden>
</CounterLabel>

If so, the counterStyles doesn't really apply to position the counter itself rather they position the string within the counter label.

Wrapper inside the CounterLabel
Screen Shot 2022-11-09 at 10 48 24 am

wrapper outside the CounterLabel (matches with the design)
Screen Shot 2022-11-09 at 10 48 32 am

Let me know if I miss anything or misunderstand!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My bad 🙇 ! The comment was more into adding all of these wrappers as part of the Counter component itself.

It seems that any other component using it, like Buttons with counters might benefit from adding the Box wrapper with the aria-hidden and the VisuallyHidden element.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Ahh Okay! Yeah, that is a great idea. CounterLabel could definitely use some help. How about I create an issue for that and we can discuss from there? I'm going to merge this pull requests as you approved but let me know if you have any concerns 🙌🏼

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Love it 👍 ❤️ !!

@broccolinisoupbroccolinisoupNov 13, 2022

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Just dropping the issue here for reference 🙂

@broccolinisoup
broccolinisoup temporarily deployed to github-pages November 9, 2022 01:00 Inactive
@broccolinisoup
broccolinisoup temporarily deployed to github-pages November 10, 2022 02:13 Inactive
@broccolinisoup
broccolinisoup temporarily deployed to github-pages November 10, 2022 02:59 Inactive
@broccolinisoup
broccolinisoup temporarily deployed to github-pages November 10, 2022 03:15 Inactive
@broccolinisoup
broccolinisoup merged commit 5bc5c70 into mainNov 10, 2022
@broccolinisoup
broccolinisoup deleted the broccolinisoup/UnderlineNav-sign-off-remediations-2 branch November 10, 2022 03:18
@primer-cssprimer-css mentioned this pull request Nov 10, 2022
Sign up for freeto 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.

2 participants

@broccolinisoup@josepmartins