Skip to content

Conversation

mejiaj
Copy link
Contributor

@mejiaj mejiaj commented Sep 27, 2022

Description

Secondary nav separator is no longer read on screenreaders. The | pseudoelement is no longer read on screen readers. Closes #4944.

Preview link

Additional information

This solution converts the separator from a pseudoelement to a border. This simplifies styles and prevents the screenreaders from reading this element.

Old

Header extended in Chrome.
image

New

Chrome
image

Firefox
image

Safari
image

Previous solution

⚠️ This solution won't work because Firefox fails to render the separator correctly. See comment below for more information.

Firefox
image


The separator uses an empty string for the pseudoelement's alt text.

content: "\007C" / "";

Based on W3 Guidance

image

  • Use entity code for pipe character (More consistent rendering)
  • Add empty alt text for pseudoelement to prevent character being read on screenreaders

Before you hit Submit, make sure you’ve done whichever of these applies to you:

  • Follow the 18F Front End Coding Style Guide and Accessibility Guide.
  • Run npm test and make sure the tests for the files you have changed have passed.
  • Title your pull request using this format: [Website] - [UI component]: Brief statement describing what this pull request solves.

- Use code for pipe character
- Add empty alt text for pseudoelement to prevent character being read on screenreaders

Based on guidance https://www.w3.org/TR/css-content-3/#alt
@thisisdano
Copy link
Contributor

Caniuse indicates this this feature doesn't have great support yet — perhaps since it's still functionality that's only in a draft spec?

That said, it this issue in the JAWS repo makes it look like JAWS does support it?

@mejiaj
Copy link
Contributor Author

mejiaj commented Jan 27, 2023

@thisisdano we were able to test in JAWS thanks to @amycole501. She confirmed this fixes the issue.

I'm happy to change it to border if we want to avoid introducing features that are still in draft.

@mejiaj
Copy link
Contributor Author

mejiaj commented Feb 2, 2023

Firefox doesn't render correctly, so this solution won't work.

From @nick-mon1:

Question

Firefox says this is an invalid value and the override fails. If I remove / "" then it works.
Any suggestions for Firefox support?

GSA/digitalgov.gov#5763


image
Preview link →

@amycole501 amycole501 marked this pull request as ready for review February 2, 2023 15:36
@mejiaj mejiaj marked this pull request as draft February 2, 2023 15:38
Comment on lines 345 to 348
& + .usa-nav__secondary-item {
border-left: 1px solid color("base-lighter");
margin-left: px-to-rem(5px);
padding-left: units(1);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternative

Alternate solution keeps the pseudo element, but creates the shape. I liked that it's similar to the current, but it's more CSS.

      & + .usa-nav__secondary-item::before {
        background-color: color("base-lighter");
        display: inline-block;
        width: units("1px");
        height: units(2);
        content: "";
        margin-right: units(0.5);
        vertical-align: middle;
      }

Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed that this solution causes some slight content shift brought on by the height setting. Here's a video of me clicking back and forth between the development build and local

Screen.Recording.2023-02-03.at.1.18.03.PM.mov

@mejiaj mejiaj marked this pull request as ready for review February 3, 2023 15:55
@mejiaj mejiaj requested review from amyleadem and mahoneycm February 3, 2023 15:55
@mahoneycm mahoneycm self-assigned this Feb 3, 2023
@mejiaj mejiaj requested a review from amycole501 February 3, 2023 18:16
@amyleadem amyleadem self-assigned this Feb 3, 2023
Copy link
Contributor

@mahoneycm mahoneycm left a comment

Choose a reason for hiding this comment

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

I think either solution would work! I like trying to keep the original border height but the benefit of less css and not having the content shift slightly might be the better move forward.

Comment on lines 345 to 348
& + .usa-nav__secondary-item {
border-left: 1px solid color("base-lighter");
margin-left: px-to-rem(5px);
padding-left: units(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed that this solution causes some slight content shift brought on by the height setting. Here's a video of me clicking back and forth between the development build and local

Screen.Recording.2023-02-03.at.1.18.03.PM.mov

@mahoneycm mahoneycm removed their assignment Feb 3, 2023
Copy link
Contributor

@amyleadem amyleadem left a comment

Choose a reason for hiding this comment

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

I like the border solution. I think it is a nice, simple way to approach it. I had one question about some CSS. Let me know what you think.

padding-right: units(0.5);
& + .usa-nav__secondary-item {
border-left: 1px solid color("base-lighter");
margin-left: px-to-rem(5px);
Copy link
Contributor

Choose a reason for hiding this comment

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

@mejiaj
I am curious about why the value is 5px here instead of matching the padding-left value of units(1). I did a little digging, and when I set the margin-left to units(1), I saw that the horizontal alignment between the elements was a bit off. Is this the reason for the 5px? If so, the misalignment seemed to resolve itself when I replaced float:right with display:flex on .usa-nav__secondary-links. Doing so also had the added benefit of making the border height a little smaller. What do you think? Am I making too many assumptions here?

Copy link
Contributor Author

@mejiaj mejiaj Feb 6, 2023

Choose a reason for hiding this comment

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

@amyleadem this is to make up for the lost whitespace from initial styling. I wasn't completely satisfied with the 5px, but it seemed like the most straightforward based on alternatives.

I'd prefer to avoid floats and messing with the layout too much, but I can see if there are any flexbox properties that could help.

@amyleadem amyleadem removed their assignment Feb 3, 2023
Copy link

@amycole501 amycole501 left a comment

Choose a reason for hiding this comment

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

Using JAWS, I didn't hear any indication of the pipe being read aloud. I tried in Chrome, Firefox and Edge. It does, though, say "Blank" instead. Not ideal but it is better than describing the pipe as a vertical line.

@mejiaj
Copy link
Contributor Author

mejiaj commented Feb 9, 2023

Additional updates

  • Removed an unnecessary float: right [ef09fcb]
  • Use flexbox and column gap for more consistent spacing on both sides of separators [units(1)] (no magic numbers like 5px) 73dacc4

Tested these updates on:

  • Safari
  • Firefox
  • Microsoft Edge (chromium)

@mejiaj mejiaj requested a review from amyleadem February 9, 2023 16:00
Copy link
Contributor

@amyleadem amyleadem left a comment

Choose a reason for hiding this comment

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

Approved!

Tested on:

  • Safari
  • Firefox
  • Chrome

@amyleadem amyleadem requested a review from thisisdano February 9, 2023 18:45
@mejiaj mejiaj self-assigned this Feb 10, 2023
Copy link
Contributor

@thisisdano thisisdano left a comment

Choose a reason for hiding this comment

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

What a smart solution!

@thisisdano thisisdano merged commit 3377e57 into develop Feb 28, 2023
@thisisdano thisisdano deleted the jm-a11y-nav-separator branch February 28, 2023 19:08
@thisisdano thisisdano mentioned this pull request Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

USWDS - Bug: secondary nav link separators are visible to screen readers
5 participants