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

[Enter] keyPress on HTMLAnchorElement #589

Closed
ph-fritsche opened this issue Mar 17, 2021 · 2 comments
Closed

[Enter] keyPress on HTMLAnchorElement #589

ph-fritsche opened this issue Mar 17, 2021 · 2 comments
Labels
accuracy Improves the accuracy of how behavior is simulated

Comments

@ph-fritsche
Copy link
Member

ph-fritsche commented Mar 17, 2021

  • @testing-library/user-event version: 13
  • Chrome 89.0.4389.90

When investigating #554 I stumbled over a strange behavior:
The browser (Chrome) does not fire a keypress event for [Enter] on an HTMLAnchorElement.
It does fire the keypress event (but no click) if the keydown occured on another element and the keydown event handler moved the focus to the HTMLAnchorElement.

Reproduction repository:

Using this to play around with events: https://codesandbox.io/s/keyevent-vtdcc?file=/src/App.js

Suggested solution:

This needs more investigation on how exactly browsers handle keyPress for [Enter]

@ph-fritsche ph-fritsche added accuracy Improves the accuracy of how behavior is simulated needs investigation Someone has to do research on this labels Mar 17, 2021
@ph-fritsche
Copy link
Member Author

There are also keypress events with repeat: true.
Also the click event triggered per Enter has pointerId: -1

@ph-fritsche
Copy link
Member Author

The behavior for Enter on <a href="something"/> is inconsistent across browsers.

In Chrome:
On a keydown with repeat=false, the browser dispatches a click event. The following keypress is omitted.
If the keydown occurred on another element, the behavior of that element is applied and the keypress is dispatched as usual.

In Firefox:
On a keypress, the browser dispatches a click event.

I couldn't find any specification on this, it seems to be up to the browser vendor how to handle interaction with hyperlinks.
So for the moment I think we'll stick to the easier implementation.

@ph-fritsche ph-fritsche closed this as not planned Won't fix, can't repro, duplicate, stale Jul 15, 2022
@ph-fritsche ph-fritsche removed the needs investigation Someone has to do research on this label Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accuracy Improves the accuracy of how behavior is simulated
Projects
None yet
Development

No branches or pull requests

1 participant