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

Added onKeyPress handler to Link. #6664

Closed
wants to merge 1 commit into from
Closed

Added onKeyPress handler to Link. #6664

wants to merge 1 commit into from

Conversation

StringEpsilon
Copy link
Contributor

Added onKeyPress handler to the Link component, which acts just like the onClick handler when either Enter or Space is pressed.

Fixes #6600

@pshrmn
Copy link
Contributor

pshrmn commented Mar 24, 2019

Hey @StringEpsilon, thanks for the PR. However, I do not believe that this is necessary because an anchor already works with the Enter key. The react-a11y warning seems more geared towards non-accessible elements. If the link has an onClick prop, it will be called when the user clicks navigates using the Enter key.

@StringEpsilon
Copy link
Contributor Author

StringEpsilon commented Mar 24, 2019

I guess you're right, as long as react router dom renders an anchor element, this isn't needed.

However, there is the feature request to render arbitrary elements via a component prop. See #5437, which is also on the roadmap for 5.1.

With a link component prop, you may or may not want to take care of a11y (in react-router). Depends on your philosophy, I guess.

@pshrmn
Copy link
Contributor

pshrmn commented Mar 24, 2019

Even with supporting <Link component>, the intention is to always render an underlying anchor. React doesn't have a good way to enforce this, but anyone that uses a non-anchor element for links is already playing with fire.

@StringEpsilon StringEpsilon deleted the Link_onKeyPress branch March 24, 2019 15:02
@lock lock bot locked as resolved and limited conversation to collaborators Jul 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add onKeyPress for Link component to respond Enter and Space by default for accessibility
2 participants