-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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: accessibility for closing hamburger menu with keyboard #8674
fix: accessibility for closing hamburger menu with keyboard #8674
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8674 +/- ##
==========================================
- Coverage 15.96% 15.93% -0.03%
==========================================
Files 89 89
Lines 4710 4718 +8
Branches 821 823 +2
==========================================
Hits 752 752
- Misses 3449 3455 +6
- Partials 509 511 +2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thank you @TanyaPina ! One UX/Accessibility change to the approach for focus out 👍
for more information, see https://pre-commit.ci
Hey @TanyaPina ! Are you still working on this one? Anything we can do to help knock it over the finish line? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm! Tested both on desktop/mobile and works like a charm! One small fix.
$('.header-dropdown').on('keydown', function (event) { | ||
if (event.key === 'Escape') { | ||
$('.header-dropdown > details[open]').not(this).removeAttr('open'); | ||
} | ||
}); | ||
|
||
$('.dropdown-menu').each(function() { | ||
$(this).find('a').last().on('focusout', function() { | ||
$('.header-dropdown > details[open]').not(this).removeAttr('open'); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see the one's above do this 😅 We also shouldn't be using .not(this)
here, since we actually do want to close this
!
Closes #7917
Issue: The user hamburger menu being unable to be closed through keyboard use, resulting in a menu that remains open even when focus is outside of it.
This PR fixes this issue by enabling the user to exit header dropdown menus with the press of the Escape key. Additionally, it traps focus in the hamburger menu list by cycling through the list items until the user chooses to exit the menu with the escape key.
Technical
While this PR applies escape key functionality to header dropdown menus, it currently fixes the focus issue within the hamburger dropdown menu specifically. A limitation with this fix would be if the user is in the last menu item and shift+tabs to go backwards, which results in them going to the first menu list item instead of the penultimate.
Testing
Screenshot
Loom video to show keyboard behavior:
https://www.loom.com/share/9f35dffdc8dd435f82a991f5be22db2a?sid=2cece70d-9271-494a-b81c-40822c6d5b85
Stakeholders