Skip to content

fix(a11y): main menu a11y updates - #45137

Merged
ahmaxed merged 34 commits into
freeCodeCamp:mainfrom
bbsmooth:fix/main-menu-a11y
Jun 1, 2022
Merged

ahmaxed merged 34 commits into
freeCodeCamp:mainfrom
bbsmooth:fix/main-menu-a11y

Conversation

@bbsmooth

Copy link
Copy Markdown
Contributor

Checklist:

  • I have read freeCodeCamp's contribution guidelines.
  • My pull request has a descriptive title (not a vague title like Update index.md)
  • My pull request targets the main branch of freeCodeCamp.
  • I have tested these changes locally on my machine.

Closes #45106

This is a big one. There are several a11y issues with the current main menu that I have attempted to fix.

  • The language picker is basically inaccessible for keyboard users. In order to keep it in the main menu I had to create a custom submenu. This is by far the majority of new code/changes in this PR.
  • The keyboard focus indicator is not consistent, and sometimes not even visible across browsers. I really feel that FCC needs to settle on a universal focus indicator color. For the time being I have chosen the --blue-mid color from the predefined color pallet for the menu because it has accessible contrast with both dark and light themes and I just think it looks nice. You'll also notice that you will only see the focus outline if you are using the keyboard to navigate the menu. The ability to do this easily with CSS has been added rather recently (and has a safe fallback for those browsers who don't recognize it).
  • Converted the menu to a list as that is the current best practice and it allows screen reader users to know how many items are in the menu.
  • Moved the avatar/sign-in button out of the menu. These are not visually located in the menu and thus should be outside of it. Also, the avatar appears to go to the same place as the Profile menu option, but that's for another discussion.
  • Some other little niceties for keyboard users such as auto-closing the menu when it loses focus and allowing the Escape key to close the menu.

I was not able to figure out how to get the various languages to serve properly, so I was not able to do an official test on the language picker to make sure it takes you to the language you pick. I would appreciate it if someone would test this for me. Also, I don't have access to Safari, so it would be great if someone who does would test this, especially the language picker, to make sure it behaves properly.

This PR is not quite ready to go as-is but it is definitely good enough for preliminary testing. There are some translations that will need to be set up. And I'm not a React expert (yet), so if I have done some things that go against best practices I'm more than happy to hear about it. Same with TypeScript. And I'm sure not every change I made will be perfect.

@bbsmooth
bbsmooth requested a review from a team February 16, 2022 02:19
@gitpod-io

gitpod-io Bot commented Feb 16, 2022

Copy link
Copy Markdown

@github-actions github-actions Bot added the platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. label Feb 16, 2022
@bbsmooth bbsmooth changed the title fix: main menu a11y updates fix(a11y): main menu a11y updates Feb 16, 2022
@ghost

ghost commented Feb 16, 2022 •

Copy link
Copy Markdown

👀 Review this PR in a CodeSee Review Map

View the CodeSee Map of this change

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

@naomi-lgbt

Copy link
Copy Markdown
Member

I was not able to figure out how to get the various languages to serve properly, so I was not able to do an official test on the language picker to make sure it takes you to the language you pick

For what it's worth, the different languages in production are entirely different instances - there's not really a way to test switching them locally without rebuilding the entire client.

@gikf gikf added the scope: a11y Threads for addressing accessibility issues. label Feb 16, 2022
@raisedadead raisedadead added the MERGE CONFLICT! To be applied to PR's that have a merge conflict and need updating label Feb 18, 2022
@ahmaxed

ahmaxed commented Feb 23, 2022

Copy link
Copy Markdown
Member

Thanks for the hard work here. Here are a few nitpicks.

  • Everything in the right side of the navigation bar should be in Lato. (Except the sign in cta button)
  • The sign in button in navigation is not centered. (For signed out users)
  • Keep the navigation section dividers to group items by functionality.

In order to be more conventional with the lang selector, I suggest having a span with the word “Language:” followed by “English” and aria-label of “Change language" or “Select Language”.
Here is an example in the footer.

I completely agree on implementing a consistent focus state. And —blue mid would be a great candidate for the reason you mentioned above.

After completing the ui library, a color system audit is due where we evaluate our accent colors and their usage.

For the time being, let us have the focus state represented as an outline: 3px solid var(--blue-mid);
For the submenu, we could go anywhere between gray-85 to gray-75 for the background, a similar hover and focus state as the main menu.

For navigating between clients, if the new language selector links to a similar url as before, it should be good to go.

Other than that the navigation is coming tougher neatly here.

@bbsmooth

Copy link
Copy Markdown
Contributor Author

The font in the menu is currently set to Roboto-Mono, sans-serif but since Roboto-Mono isn't an actual font name (it should be Roboto Mono without the dash) then the font is falling back to sans-serif. I have changed my PR to use sans-serif but if this is not the actual intended font then let me know what it should be.

@bbsmooth

bbsmooth commented Mar 21, 2022 •

Copy link
Copy Markdown
Contributor Author

In order to be more conventional with the lang selector, I suggest having a span with the word “Language:” followed by “English” and aria-label of “Change language" or “Select Language”.

This is actually a violation of WCAG 2.5.3 Label in Name. (Yes, Khan Academy is in violation of this guideline.) This guideline says that the accessible name (which would be the text in aria-label in the Khan example) must include the text in the visible label for the control. So we can't have the visible text for the language picker be something like "Language: English" and then set the accessible name (using aria-label) to something like "Change language". We would at least need to add the current language in the accessible name. And best practices are that the visible label is at the very beginning of the accessible name, which I don't think would make a lot of sense here.

The way I have it implemented now, there is no need for aria-label because the accessible name is just the text in the button ('Change Language'). Personally, I didn't think it was necessary to show the current language since the language would be shown in that language's font. So for example, if you can't read Chinese, and the page is currently in Chinese, then I'm not sure what good it would do to have the language picker actually show the language name since only people who can read Chinese would understand it, and they probably don't need to be told what language they are currently reading.

I think what would be more useful would be to find an icon that represents a language picker (I'm not sure what that would be at the moment) and then if somebody accidentally switches to a language they can't read at least they would be able to find the language picker easily by recognizing the icon.

@bbsmooth

Copy link
Copy Markdown
Contributor Author
  • Everything in the right side of the navigation bar should be in Lato. (Except the sign in cta button)

  • The sign in button in navigation is not centered. (For signed out users)

  • Keep the navigation section dividers to group items by functionality.

I have fixed these issues and also a few minor touch-ups of issues I overlooked initially. Eagerly awaiting more feedback. If everyone feels that the language picker needs to show the current language then I will work on making that as accessible as possible.

@ahmaxed

ahmaxed commented Mar 23, 2022

Copy link
Copy Markdown
Member

I agree with your reasoning, let's keep it as "change language".

I think the globe icon is a good candidate. We might consider replacing it with the drop down icon.
As of the styles, let's do Latto for everything in the dropdown menu and the language menu.

On a second thought, let's change the background of the language menu to a lighter gray shade( between gray-85 to gray-75), and keep the hover state on nav menu and language menu identical to what it was previously.
We are rethinking our buttons' states, and will roll the changes across platforms once we finish the v1 of our component library.

This seems to be coming together nicely. Thanks a lot for your efforts.

@bbsmooth

Copy link
Copy Markdown
Contributor Author

I searched for "language icon" and found a possible candidate which I have added to the main menu. Let me know if you like it or if you want me to keep trying.

As for the colors on the language menu, FCC is currently using a <select> for this menu and I don't believe you can style it much with CSS, so the colors you are seeing are determined by the OS/browser. I tried to mimic the colors used on Windows/Linux the best I could. I think the blue hover is pretty close. I could make the background a slightly darker shade of gray but I wouldn't go too much darker or we'll have to turn the text white. Personally, I think the contrast of the light background compared with the dark background of the main menu makes it stand out better, but I'm not a designer so take that with a grain of salt. Let me know if you still want any changes to it.

@ahmaxed

ahmaxed commented Apr 1, 2022

Copy link
Copy Markdown
Member

Everything looks great.

Here are the final touches:

  • font of the toggle menu and the language menu should be Lato.
  • background color of the language menu should be var(--gray-80);
  • color of the language menu should be same as the toggle menu.
  • checkmark color should be the same as the font color
  • The globe should replace the dropdown icon.
  • hover color/background of the ui elements should stay as the following for consistency:
color: var(--theme-color);
background-color: var(--gray-10);

(We will incorporate that blue background further in the component library.)

Here are a few quick mocks.

Screen Shot 2022-04-01 at 2 55 58 PM

Screen Shot 2022-04-01 at 2 58 11 PM

(the checkmark is missing)

@bbsmooth

Copy link
Copy Markdown
Contributor Author

@ahmadabdolsaheb Thank you for the mock-ups, this made it much clearer as to what you want. I believe I got it all but let me know if I missed something. If this looks good to go I believe we just need to add a translation for "Change Language".

@ahmaxed
ahmaxed force-pushed the fix/main-menu-a11y branch from 5ef5004 to c85c7a5 Compare April 19, 2022 12:38
@ahmaxed

ahmaxed commented Apr 19, 2022 •

Copy link
Copy Markdown
Member

In addition to adding the menuButtonRef: {} as Ref<HTMLButtonElement>, hideMenu: jest.fn() to the LandingPageProps in the header.test.tsx, the header.test.tsx itself needs to be restructured.

Since the tests are tightly coupled with the previous structure of the navigation components, I wonder if they should be replaced with cypress tests instead.

@github-actions github-actions Bot added scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc. scope: i18n language translation/internationalization. Often combined with language type label labels Apr 20, 2022
ahmaxed
ahmaxed previously approved these changes Apr 21, 2022
@ahmaxed ahmaxed added status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. and removed MERGE CONFLICT! To be applied to PR's that have a merge conflict and need updating labels Apr 21, 2022
Comment thread client/src/components/Header/index.tsx Resolved
@bbsmooth
bbsmooth force-pushed the fix/main-menu-a11y branch from 901d3e6 to 426e60b Compare April 24, 2022 15:48
@github-actions github-actions Bot removed scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc. scope: i18n language translation/internationalization. Often combined with language type label labels Apr 24, 2022
@bbsmooth

Copy link
Copy Markdown
Contributor Author

@ahmadabdolsaheb Good call on changing the name of displayLanguageMenu. I also fixed a small minor annoyance concerning the onBlur event closing the menu too early if the focus was on one of the last two items in the main menu. Only keyboard users who first put the focus on one of those items and then used their mouse to close the menu by clicking the main Menu button would have noticed it, but I wouldn't be able to sleep at night if I left it in there.

@ahmaxed
ahmaxed force-pushed the fix/main-menu-a11y branch from 057e69b to e6bd7ea Compare May 31, 2022 11:23
ahmaxed
ahmaxed previously approved these changes May 31, 2022
@ahmaxed

ahmaxed commented May 31, 2022 •

Copy link
Copy Markdown
Member

@emmalearnscode, thanks for taking a look. Yes we will gradually roll out the focus styles to all of our components in this repository.

@bbsmooth, thanks for all the hard work. Looking forward to see this in production.

@moT01 moT01 self-assigned this May 31, 2022

@moT01 moT01 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Well, I looked over this pretty hard. There's a lot of conversation here - I tried to read, or at least skim over, all of it - I apologize if I missed some context or explanation - here's everything I found...

I was a little confused with using the tab key then switching to the arrows for the menu, too. I picked up on it quick.

The language links all look to be working.

On Safari 13.1.2 - pretty old version - there's quite a few issues with it. Tab order seems off - I hit enter on the menu and then tab takes me to 'night mode', and 'change language' after that. All the other options get skipped. It also skips over the avatar/profile icon. Well, none of it is even reachable on production with that version of Safari - so it’s an improvement - since that’s the case, I wouldn’t let that hold back this PR. I tried looking into it a little, didn’t see what the cause was. Did anyone else (@ahmadabdolsaheb) get a chance to test this on a newer Safari? I do think this might be something to try and look into with another PR - The nav is heavily used so it might be worth making it more compatible than other things like a lone curriculum test.

There did seem to be a minor style issue with the search on smaller windows...
Production - search lines up with whatever button is above it:
Screen Shot 2022-05-31 at 2 42 46 PM
This PR - search goes behind the scroll bar:
Screen Shot 2022-05-31 at 2 43 04 PM

I left a few minor suggestions below.

That's really all I found? I must be losing it - or this just looks really good. It looks real good @bbsmooth 🎉 Nice job 👍 Here's some quotes from you: "I'm not a React expert" ... "Same with TypeScript." Whatever you say. I would be good with merging it like this if we want.

Edit: This has been around a while and had a lot of work put in. All the things I found are quite minor - if you're ready to be done with it, @bbsmooth - let me know and we can merge it.

@bbsmooth

Copy link
Copy Markdown
Contributor Author

@moT01

On Safari 13.1.2 - pretty old version - there's quite a few issues with it. Tab order seems off - I hit enter on the menu and then tab takes me to 'night mode', and 'change language' after that. All the other options get skipped.

Wow, I was not expecting that. I know that there can be issues with the VoiceOver screen reader and Safari if the list has had the default bullet styling removed, but I don't think I've heard of it being a problem when not using VO. The solution for the VO issue is to add role='list' to the list, which apparently reminds VO that it is a list even though it doesn't have bullets. On a long shot, I went ahead and added the list role. Can you try it again and see if it made any difference? If not, then I'll have to do some research. But ya, since it doesn't work at all on production at least it's a slight improvement. But I hope this wouldn't hold up this PR, it's been long enough in the making.

@bbsmooth

bbsmooth commented Jun 1, 2022

Copy link
Copy Markdown
Contributor Author

@moT01

There did seem to be a minor style issue with the search on smaller windows...

You'd think by now all browsers would handle CSS the same but of course this is an instance where it looked good in FF but not the others. Someday I'll learn that you've got to test everything in every browser.

I think I've got this looking good in all of them now.

@moT01

moT01 commented Jun 1, 2022

Copy link
Copy Markdown
Member

The solution for the VO issue is to add role='list'...

No, that didn't change anything @bbsmooth.

I found the issue though, it was a safari setting.

@bbsmooth

bbsmooth commented Jun 1, 2022

Copy link
Copy Markdown
Contributor Author

I found the issue though, it was a safari setting.

Oh ya, I completely forgot about that issue. I had heard of it before, but since I don't have a mac it just wasn't one that popped into my head. I'll remove the extraneous list role and I think we are ready to to.

@moT01 moT01 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 🎉

Want to take one last look and get this in when you get up @ahmadabdolsaheb

@ahmaxed
ahmaxed merged commit d233209 into freeCodeCamp:main Jun 1, 2022
@bbsmooth
bbsmooth deleted the fix/main-menu-a11y branch June 1, 2022 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform: learn UI side of the client application that needs familiarity with React, Gatsby etc. scope: a11y Threads for addressing accessibility issues. scope: i18n language translation/internationalization. Often combined with language type label scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc. status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Language picker inaccessibility

9 participants