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

Event Handler not reaching Link component #181

Open
TylerAPfledderer opened this issue Oct 17, 2023 · 1 comment
Open

Event Handler not reaching Link component #181

TylerAPfledderer opened this issue Oct 17, 2023 · 1 comment

Comments

@TylerAPfledderer
Copy link

TylerAPfledderer commented Oct 17, 2023

Hello!

Please see this minimal repo using the Link component, as well as the Link component and Menu components from Chakra UI.

I am contributing to a project that is using these packages and updating their main navigation to use the Menu components. Per Chakra usage, MenuItem normally renders a button, but can be a link. With a11y, you navigate the menu items via the arrow keys and not Tab.

In the project, ChakraLink is consuming the Link of this i18next package for the theming, then this custom component is consumed by MenuItem

The current issue is that this approach prevents the execution of onKeyDown event happening under the hood from the Chakra package. This event is being passed via MenuLink to MenuItem.

Could the innerRef being used by i18next Link be preventing this handler?

With the minimal repo, do the following:

  1. Click "Open Menu" so the two list items appear
  2. Press the down arrow key, and notice no default focus styles.
  3. In the component file, replace BaseLink with "a" for both MenuItems's then repeat the process to see the default focus styles on press of the down arrow key.

For references:

@pettinarip
Copy link

Good catch @TylerAPfledderer!

I've forked the shared example, tested it by using the native Gatsby Link and it fails as well. So, seems to me that this is a problem with the Gatsby Link itself and/or the reach router link.

As far as I could see, Gatsby is use the innerRef prop but in the Reach Router docs it says that innerRef should only be used with react < v16.4 (while gatsby-link has react 18 as peer dep).

Not sure if that could be the source of the problem here.

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

No branches or pull requests

2 participants