You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
@testing-library/user-event
version: 13When 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 noclick
) if thekeydown
occured on another element and thekeydown
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]
The text was updated successfully, but these errors were encountered: