playcanvas / playcanvas/engine

Element still recieves touchend event if useInput=false

Open
#3,687 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

The element dragging described here uses the ElementDragHelper object.

If an element starts to be dragged via mouse, and useInput is set to false on the dragging element after this, when it is dropped the element does not receive the "mouseup" event. This is the desired behavior as it allows me to know which element this dragged element was "dropped on" (The element under the cursor when the drag ends). This allows for UI drag and drop functionality.

The issue is that when touch is used (Desktop Google chrome touch emulation), the dragged element receives the touchend event, even if useInput is set to false. This is not desired, as the element under gets no event (because the dragged one got the event), meaning I cannot know what element should receive this drop.

Steps to Reproduce
  1. Setup a new ElementDragHelper on an element.
  2. Use google chrome mobile viewport: https://developer.chrome.com/docs/devtools/device-mode/#viewport (reload Launch tab otherwise touch doesn't work properly).
  3. Using the "drag:start" event from the ElementDragHelper object, set useInput to false on the element.
  4. Observe how when dragging ends via touch, the dragged element still receives "touchEnd", if it was under the touch pointer.
  5. Repeat and observe how the element does not receive "mouseup" if it was under the cursor.

In my implementation, i use requestAnimationFrame() to wait a frame before setting useInput to false, but I do not think this should matter.

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.

Research direction

Start by tracing ElementDragHelper's drag:start handling and the touchend and mouseup input paths. Reproduce the issue in Chrome mobile viewport with useInput set to false during dragging, then compare event targeting when the drag ends. Done means touch behavior matches mouse behavior: the dragged element does not receive touchend when useInput is false, allowing the element beneath it to receive the drop event.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.