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

Make NavMenu Keyboard Navigable #5772

Merged
merged 3 commits into from
Jan 15, 2021
Merged

Make NavMenu Keyboard Navigable #5772

merged 3 commits into from
Jan 15, 2021

Conversation

andrico1234
Copy link
Contributor

I've tested this manually.

I haven't added any unit tests, but I'll be happy to add an integration test that ensures that the menu item is reachable via the tab button.

tab.index.mov

@@ -16,7 +16,7 @@ import Tooltip, { TooltipProps } from '@material-ui/core/Tooltip';
import { makeStyles } from '@material-ui/core/styles';

const NavLinkRef = forwardRef<HTMLAnchorElement, NavLinkProps>((props, ref) => (
<NavLink innerRef={ref} {...props} />
<NavLink innerRef={ref} {...props} tabIndex={0} />
Copy link
Contributor Author

@andrico1234 andrico1234 Jan 14, 2021

Choose a reason for hiding this comment

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

it looks like the {...props} spread operator contains a tabIndex={-1} which would override the one I explicitly pass through if I were to pass it before the spreaded props.

I'm not sure what the most appropriate way to handle this. The way I've done it is most straightforward, but it currently prevents users from enabling/disabling tabbing on their own accord. Is this configuration that we'd want to give users?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is because material UI MenuItem set it to -1 when not specified. You should add this tabIndex prop to the MenuItem component below in the same file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good shout, it feels much more appropriate being set in MenuItem, I've pushed the changes.

@fzaninotto
Copy link
Member

Nice! Indeed, an integration test would be welcome.

Copy link
Contributor

@djhi djhi left a comment

Choose a reason for hiding this comment

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

Excellent, thanks!

@djhi djhi added this to the 3.12 milestone Jan 15, 2021
@fzaninotto fzaninotto merged commit 9b1eac4 into marmelab:next Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants