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

Fix #1409 -- Add Keyboard Accessibility To Hamburger Menu #1418

Merged

Conversation

ontowhee
Copy link
Contributor

@ontowhee ontowhee commented Oct 20, 2023

Fix for #1409

This changes the menu button from a div to a button element so the keyboard is able to tab to it. The border is set to 0 to override the default button border style.

Before - It wasn't able to tab to the menu button
Screenshot from 2023-10-20 06-33-11

After - It is able to tab to the menu button with the red border around it
Screenshot from 2023-10-20 08-11-08

Other notes

  • When you tab to the menu it should be obvious you're on it (look how the dark mode button works), probably using css :focus selector It already shows a red outline when you tab to it.
  • When you hit space it should activate, again like the dark mode toggle It already does open/close the menu when you hit SPACE or ENTER.
  • When the menu is open, the first time we press the tab key, it should bring the focus to the first menu item on the list. Right now it jumps to the light/dark theme button.
  • Should the menu button be in a nav element?
  • Should there be aria-expanded and aria-label attributes on the menu button?
  • When the menu is closed and you hit tab, should the focus go first to the light/dark theme button, and then to the menu button?

@ontowhee ontowhee changed the title Add Keyboard Accessibility To Hamburger Menu Fix #1409 -- Add Keyboard Accessibility To Hamburger Menu Oct 20, 2023
@ontowhee ontowhee marked this pull request as ready for review October 20, 2023 14:50
@knyghty
Copy link
Member

knyghty commented Oct 20, 2023

@thibaudcolas what do you think?

This doesn't fix the issue that you can tab through the links without expanding the nav but this still seems like an improvement.

Copy link
Member

@thibaudcolas thibaudcolas left a comment

Choose a reason for hiding this comment

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

Working great! Thank you @ontowhee

@ontowhee
Copy link
Contributor Author

ontowhee commented Nov 15, 2023

@thibaudcolas @CuriousLearner Thank you for the approval! Do we want to create an issue for the "Other Notes" mentioned in the description above?

Is this a duplicate of PR #1400?

@sabderemane sabderemane merged commit c14949c into django:main Nov 16, 2023
1 check passed
@thibaudcolas
Copy link
Member

When the menu is open, the first time we press the tab key, it should bring the focus to the first menu item on the list. Right now it jumps to the light/dark theme button.

Yes – please open an issue

Should the menu button be in a nav element?

I don’t think it matters too much

Should there be aria-expanded and aria-label attributes on the menu button?

aria-expanded definitely

When the menu is closed and you hit tab, should the focus go first to the light/dark theme button, and then to the menu button?

I’d expect the focus to go first to a "Skip link" on the page (#1367), then to the Django logo, then theme toggle, then menu toggle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

BLOCKER - The "hamburger" menu toggle is impossible to use with a keyboard
5 participants