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
merged 7 commits into from
Aug 2, 2022
Merged

Conversation

ph-fritsche
Copy link
Member

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

What:

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

feat:

  • pointer: dispatch auxclick events

fix:

  • 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

Why:

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

How:

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.

Checklist:

  • Tests
  • Ready to be merged

@codesandbox-ci
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

@codecov
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
@github-actions
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 📦🚀

CrispyBaguette pushed a commit to CrispyBaguette/wasm-palette-converter that referenced this pull request Nov 8, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@testing-library/user-event](https://github.com/testing-library/user-event) | dependencies | minor | [`14.1.1` -> `14.5.2`](https://renovatebot.com/diffs/npm/@testing-library%2fuser-event/14.1.1/14.5.2) |

---

### Release Notes

<details>
<summary>testing-library/user-event (@&#8203;testing-library/user-event)</summary>

### [`v14.5.2`](https://github.com/testing-library/user-event/releases/tag/v14.5.2)

[Compare Source](testing-library/user-event@v14.5.1...v14.5.2)

##### Bug Fixes

-   remove interop and deep DTL imports ([6a3c896](testing-library/user-event@6a3c896))

### [`v14.5.1`](https://github.com/testing-library/user-event/releases/tag/v14.5.1)

[Compare Source](testing-library/user-event@v14.5.0...v14.5.1)

##### Bug Fixes

-   incorrect default import from [@&#8203;testing-library/dom](https://github.com/testing-library/dom) ([#&#8203;1162](testing-library/user-event#1162)) ([d7483f0](testing-library/user-event@d7483f0))

### [`v14.5.0`](https://github.com/testing-library/user-event/releases/tag/v14.5.0)

[Compare Source](testing-library/user-event@v14.4.3...v14.5.0)

##### Bug Fixes

-   **exports:** add a named export for userEvent ([4019cee](testing-library/user-event@4019cee)), closes [#&#8203;1146](testing-library/user-event#1146)

##### Features

-   **types:** Add additional type exports for UserEvent & Options ([#&#8203;1112](testing-library/user-event#1112)) ([da00e8d](testing-library/user-event@da00e8d))

### [`v14.4.3`](https://github.com/testing-library/user-event/releases/tag/v14.4.3)

[Compare Source](testing-library/user-event@v14.4.2...v14.4.3)

##### Bug Fixes

-   **build:** add `types` field in `exports` ([#&#8203;1029](testing-library/user-event#1029)) ([5bed8c6](testing-library/user-event@5bed8c6))
-   remove circular dependencies ([#&#8203;1027](testing-library/user-event#1027)) ([1aa2027](testing-library/user-event@1aa2027))

### [`v14.4.2`](https://github.com/testing-library/user-event/releases/tag/v14.4.2)

[Compare Source](testing-library/user-event@v14.4.1...v14.4.2)

##### Bug Fixes

-   **build:** add `exports` field ([#&#8203;1022](testing-library/user-event#1022)) ([7839e29](testing-library/user-event@7839e29))

### [`v14.4.1`](https://github.com/testing-library/user-event/releases/tag/v14.4.1)

[Compare Source](testing-library/user-event@v14.4.0...v14.4.1)

##### Bug Fixes

-   **build:** transpile to es2019 syntax ([#&#8203;1016](testing-library/user-event#1016)) ([4291cb8](testing-library/user-event@4291cb8))

### [`v14.4.0`](https://github.com/testing-library/user-event/releases/tag/v14.4.0)

[Compare Source](testing-library/user-event@v14.3.0...v14.4.0)

##### Features

-   **pointer**: dispatch `auxclick` events ([#&#8203;1003](testing-library/user-event#1003)) ([2852509](testing-library/user-event@2852509))

##### Bug Fixes

-   **event:** be robust against incomplete event implementations ([#&#8203;1009](testing-library/user-event#1009)) ([289828b](testing-library/user-event@289828b))
-   **upload:** be robust against missing FileList implementation ([#&#8203;1007](testing-library/user-event#1007)) ([a46b4d7](testing-library/user-event@a46b4d7))
-   **keyboard**: switch modifier state of lock keys on the correct event ([#&#8203;1003](testing-library/user-event#1003)) ([2852509](testing-library/user-event@2852509))
-   **keyboard**: remove platform-specific additional key events for `Control` on `AltGraph` ([#&#8203;1003](testing-library/user-event#1003)) ([2852509](testing-library/user-event@2852509))
-   **pointer**: dispatch `contextmenu` events with `detail: 0` ([#&#8203;1003](testing-library/user-event#1003)) ([2852509](testing-library/user-event@2852509))
-   **pointer**: always set `PointerEvent.isPrimary` ([#&#8203;1003](testing-library/user-event#1003)) ([2852509](testing-library/user-event@2852509))
-   **pointer**: set `button` property on pointer events separately from legacy mouse events ([#&#8203;1003](testing-library/user-event#1003)) ([2852509](testing-library/user-event@2852509))
-   **pointer**: click closest common ancestor if `mousedown` and `mouseup` happen on different elements ([#&#8203;1003](testing-library/user-event#1003)) ([2852509](testing-library/user-event@2852509))
-   **pointer**: omit click event on release if another button is released first ([#&#8203;1003](testing-library/user-event#1003)) ([2852509](testing-library/user-event@2852509))
-   **pointer**: dispatch `mouseover`, `mouseenter` and `mousemove` on disabled elements ([#&#8203;1003](testing-library/user-event#1003)) ([2852509](testing-library/user-event@2852509))
-   **pointer**: prevent `mouse*` events per `pointerdown` event handler ([#&#8203;1003](testing-library/user-event#1003)) ([2852509](testing-library/user-event@2852509))
-   **pointer**: dispatch `*out` and `*over` events when moving into / out of nested elements ([#&#8203;1003](testing-library/user-event#1003)) ([2852509](testing-library/user-event@2852509))
-   **pointer**: dispatch `*enter` and `*leave` events on ancestors ([#&#8203;1003](testing-library/user-event#1003)) ([2852509](testing-library/user-event@2852509))

### [`v14.3.0`](https://github.com/testing-library/user-event/releases/tag/v14.3.0)

[Compare Source](testing-library/user-event@v14.2.6...v14.3.0)

##### Features

-   **keyboard:** change radio group per arrow keys ([#&#8203;995](testing-library/user-event#995)) ([e1c22af](testing-library/user-event@e1c22af))

### [`v14.2.6`](https://github.com/testing-library/user-event/releases/tag/v14.2.6)

[Compare Source](testing-library/user-event@v14.2.5...v14.2.6)

##### Bug Fixes

-   **document:** reduce impact of React@17 workaround ([#&#8203;992](testing-library/user-event#992)) ([9816d38](testing-library/user-event@9816d38))
-   **pointer:** do not throw for `pointer-events: none` on previous target ([#&#8203;991](testing-library/user-event#991)) ([6e4058b](testing-library/user-event@6e4058b))

### [`v14.2.5`](https://github.com/testing-library/user-event/releases/tag/v14.2.5)

[Compare Source](testing-library/user-event@v14.2.4...v14.2.5)

##### Bug Fixes

-   **document:** do not track `value` on `HTMLSelectElement` ([#&#8203;989](testing-library/user-event#989)) ([77a7fa8](testing-library/user-event@77a7fa8))

### [`v14.2.4`](https://github.com/testing-library/user-event/releases/tag/v14.2.4)

[Compare Source](testing-library/user-event@v14.2.3...v14.2.4)

##### Bug Fixes

-   use `window.FileList` instead of implicit global ([c88865d](testing-library/user-event@c88865d))

### [`v14.2.3`](https://github.com/testing-library/user-event/releases/tag/v14.2.3)

[Compare Source](testing-library/user-event@v14.2.2...v14.2.3)

##### Bug Fixes

-   **document:** use setters/methods on element as default ([#&#8203;987](testing-library/user-event#987)) ([c40e614](testing-library/user-event@c40e614))

### [`v14.2.2`](https://github.com/testing-library/user-event/releases/tag/v14.2.2)

[Compare Source](testing-library/user-event@v14.2.1...v14.2.2)

##### Bug Fixes

-   **document:** track `HTMLInputElement.setRangeText()` ([#&#8203;984](testing-library/user-event#984)) ([73443ec](testing-library/user-event@73443ec))

### [`v14.2.1`](https://github.com/testing-library/user-event/releases/tag/v14.2.1)

[Compare Source](testing-library/user-event@v14.2.0...v14.2.1)

##### Performance Improvements

-   **tab:** avert visibility check on irrelevant elements ([#&#8203;967](testing-library/user-event#967)) ([d2d8a39](testing-library/user-event@d2d8a39))

### [`v14.2.0`](https://github.com/testing-library/user-event/releases/tag/v14.2.0)

[Compare Source](testing-library/user-event@v14.1.1...v14.2.0)

##### Features

-   report element with declaration in `pointerEventsCheck` ([#&#8203;950](testing-library/user-event#950)) ([31b7091](testing-library/user-event@31b7091))

##### Bug Fixes

-   guard against selection without range ([#&#8203;953](testing-library/user-event#953)) ([ab78f3f](testing-library/user-event@ab78f3f))
-   **selectOptions:** wait after each click ([#&#8203;951](testing-library/user-event#951)) ([7ea7a77](testing-library/user-event@7ea7a77))
-   wait after each method before leaving `asyncWrapper` ([#&#8203;952](testing-library/user-event#952)) ([6f55fee](testing-library/user-event@6f55fee))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4xNDIuNSIsInVwZGF0ZWRJblZlciI6IjM4LjE0Mi41IiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=-->

Reviewed-on: https://gitea.bruyant.xyz/alexandre/PaletteSwitcher/pulls/47
Co-authored-by: Renovate <renovate@bruyant.xyz>
Co-committed-by: Renovate <renovate@bruyant.xyz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment