🐛 Fix sidebar block drag on Android touch devices - #2569
Open
anishshetty24 wants to merge 1 commit into
Open
Conversation
Migrate sidebar drag initialization from mouse events to pointer events so that dragging new blocks from the sidebar works on Android tablets and iPads (touch-only devices). Previously, the drag lifecycle used: - onMouseDown to start drag - mousemove to track position - mouseup to end drag Android Chrome does not fire mouse events for touch interactions, so the drag never started when using touch input. The fix replaces all mouse event handlers with pointer events, which fire for mouse, touch, and stylus input uniformly: - onPointerDown to start drag - pointermove to track position - pointerup to end drag This is consistent with how other parts of the builder (canvas blocks, endpoints, selection menu) already handle touch input. Files changed: - BlocksSideBar.tsx: mousemove/mouseup → pointermove/pointerup global listeners; initBlockDragging/initEventDragging accept PointerEvent - BlockCardLayout.tsx: onMouseDown → onPointerDown on button element - EventCardLayout.tsx: onMouseDown → onPointerDown on button element - BlockCard.tsx: prop type updated to onPointerDown - EventCard.tsx: prop type updated to onPointerDown - ForgedBlockCard.tsx: prop type updated to onPointerDown Fixes: baptisteArno#2565
|
@anishshetty24 is attempting to deploy a commit to the Typebot Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #2565
On Android tablets and iPads (touch-only devices), dragging new blocks from the left sidebar into the canvas never worked. The drag operation would never start.
Existing blocks on the canvas could be moved with touch (already used pointer events), but initiating a new block drag from the sidebar failed silently.
Root Cause
The sidebar drag lifecycle was built entirely on Mouse Events:
Before - only works with mouse:
onMouseDown to start drag
mousemove to track position
mouseup to end drag
Android Chrome does not fire mousedown/mousemove/mouseup for touch interactions - it fires Touch Events instead. So handleMouseDown was never called and the drag never started.
Fix
Migrate the sidebar drag system from Mouse Events to Pointer Events, which fire for mouse, touch, and stylus input uniformly - exactly what is already used in other parts of the builder (canvas blocks, endpoints, selection menu).
After - works with mouse + touch + stylus:
onPointerDown to start drag
pointermove to track position
pointerup to end drag
Files Changed
Testing
To test in Chrome DevTools: