playcanvas / playcanvas/engine

ElementTouchEvent uses wrong type for its touches

Open
#7,927 0 comments 1 reaction 1 assignee View on GitHub

Nobody has claimed this yet.

area: input
Dominant language
JavaScript
Stars
16.8k
Forks
2k
Avg merge
4h 32m
Merged PRs (30d)
222

Description

Hey everyone,

When I try to access the id-field on touches contained within an ElementTouchEvent, I always receive undefined. Upon further inspection, it turns out touches contained within ElementTouchEvent are of the DOM Touch-type rather than ElementTouchEvent.Touch as declared by the most recent PlayCanvas type definitions (playcanvas@2.10.6 from NPM).

Here's a screenshot of VSCode showing the type of the touch-field on an ElementTouchEvent:

Image

Here's a confirmation through some debugging that the touch event I receive from my ElementComponent is in fact of type ElementTouchEvent, and that touches contained within are of the DOM Touch-type:

Image

It turns out that element-input.js in the engine just passes the native Touches it receives straight into a new ElementTouchEvent rather than converting them:

Image

Just for clarity, the constructor of ElementTouchEvent doesn't convert the touches either.

I guess either the type definitions pulled from NPM are incorrect, or the touches should have been converted to the appropriate type so that the id-field on touches can be used as expected.

Can someone please address this?
Thanks a bunch! 💪

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.