playcanvas / playcanvas/engine
ElementTouchEvent uses wrong type for its touches
Nobody has claimed this yet.
- 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:
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:
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:
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.