-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
fix/The toggle navigation menu button is not keyboard accessible #7933
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -55,7 +55,17 @@ const NavBar: FC<PropsWithChildren<NavbarProps>> = ({ | |||||||||||
className={style.sidebarItemTogglerLabel} | ||||||||||||
htmlFor="sidebarItemToggler" | ||||||||||||
role="button" | ||||||||||||
tabIndex={0} | ||||||||||||
aria-label={sidebarItemTogglerAriaLabel} | ||||||||||||
onKeyDown={e => { | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switch to
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need an onKeyDown? It worked fine without one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. onKeyDown will open the navInteractionIcon by pressing enter or space when the navInteractionIcon is in focused state. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you want me to add or remove something then please let me know. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't have an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't think so as we have to mimic the click event by pressing tab and enter on the navInteractionIcon, |
||||||||||||
if (e.key === 'Enter' || e.key === ' ') { | ||||||||||||
e.preventDefault(); | ||||||||||||
const input = document.getElementById( | ||||||||||||
'sidebarItemToggler' | ||||||||||||
) as HTMLInputElement; | ||||||||||||
input?.click(); // Triggers input toggle | ||||||||||||
Comment on lines
+63
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than querying the DOM directly with
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||
} | ||||||||||||
}} | ||||||||||||
> | ||||||||||||
{navInteractionIcons[isMenuOpen ? 'close' : 'show']} | ||||||||||||
</Label.Root> | ||||||||||||
|
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.
Consider using a native element instead of a with role="button" and tabIndex, so you get built-in keyboard support and proper semantics without custom handlers.
Copilot uses AI. Check for mistakes.