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

separate input devices from pointer/keyboard API #1003

merged 7 commits into from
Aug 2, 2022


Copy link

@ph-fritsche ph-fritsche commented Jul 28, 2022


Extract the logic how input devices and user agent create events from the API that describes the interaction.


  • pointer: dispatch auxclick events


  • keyboard: switch modifier state of lock keys on the correct event
  • keyboard: remove platform-specific additional key events for Control on AltGraph
  • pointer: dispatch contextmenu events with detail: 0
  • pointer: always set PointerEvent.isPrimary
  • pointer: set button property on pointer events separately from legacy mouse events
  • pointer: click closest common ancestor if mousedown and mouseup happen on different elements
  • pointer: omit click event on release if another button is released first
  • pointer: dispatch mouseover, mouseenter and mousemove on disabled elements
  • pointer: prevent mouse* events per pointerdown event handler
  • pointer: dispatch *out and *over events when moving into / out of nested elements
  • pointer: dispatch *enter and *leave events on ancestors


Closes #1000
Closes #999
Closes #998
Closes #997
Closes #957


These changes extract the System which is supposed to contain the state of input devices and the logic how the user agent handles their signals.
This reduces complexity of the code by separating these concerns and eases comparing the implementation with specifications and observations in the browser.


  • Tests
  • Ready to be merged

Copy link

codesandbox-ci bot commented Jul 28, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 38e4cc4:

Sandbox Source
userEvent-dom Configuration
userEvent-react Configuration
quizzical-banzai-nr9lw5 Issue #957
userevent - pointer - click Issue #997
userevent - pointer - prevent mouse Issue #998
userevent - keyboard - prevent Issue #999
userevent - keyboard - modifiers Issue #1000

Copy link

codecov bot commented Jul 28, 2022

Codecov Report

Merging #1003 (38e4cc4) into main (1c156c2) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              main     #1003    +/-   ##
  Coverage   100.00%   100.00%            
  Files           87        85     -2     
  Lines         1876      2058   +182     
  Branches       679       706    +27     
+ Hits          1876      2058   +182     
Impacted Files Coverage Δ
src/convenience/hover.ts 100.00% <ø> (ø)
src/event/createEvent.ts 100.00% <ø> (ø)
src/event/index.ts 100.00% <ø> (ø)
src/keyboard/keyMap.ts 100.00% <ø> (ø)
src/keyboard/parseKeyDef.ts 100.00% <ø> (ø)
src/options.ts 100.00% <ø> (ø)
src/pointer/keyMap.ts 100.00% <ø> (ø)
src/pointer/parseKeyDef.ts 100.00% <ø> (ø)
src/setup/config.ts 100.00% <ø> (ø)
src/setup/index.ts 100.00% <ø> (ø)
... and 19 more

Help us with your feedback. Take ten seconds to tell us how you rate us.

@ph-fritsche ph-fritsche marked this pull request as ready for review July 29, 2022 13:34
@ph-fritsche ph-fritsche merged commit 2852509 into main Aug 2, 2022
@ph-fritsche ph-fritsche deleted the fix-pointer branch August 2, 2022 12:31
Copy link

github-actions bot commented Aug 2, 2022

🎉 This PR is included in version 14.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment