fix: Add touchcancel handler to prevent stuck gesture state#325
fix: Add touchcancel handler to prevent stuck gesture state#325upendra512 wants to merge 1 commit intoAOSSIE-Org:mainfrom
Conversation
Implement handleTouchCancel to properly clean up gesture state when touch sequences are interrupted by OS or browser events (notifications, system gestures, focus loss, etc.). Changes: - Add handleTouchCancel function that clears all touch tracking - Clear draggingTimeout to prevent spurious click events - Release active drag state if present - Reset all gesture state (tracking, moved, pinch, released count) - Update TouchArea interface and component to wire up the handler - ScreenMirror automatically receives handler via spread operator This prevents stuck drag states and pressed inputs that previously occurred when touchcancel events were unhandled, significantly improving mobile UX reliability. Fixes AOSSIE-Org#75 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
Fixes Issue #75 - Handle touchcancel to prevent stuck drag or pressed input state
Implemented comprehensive touchcancel handling to ensure gesture state is properly cleaned up when touch sequences are interrupted by OS or browser events.
Problem
The gesture tracking system handles touchstart, touchmove, and touchend events, but did not handle touchcancel. On mobile devices, touch sequences can be interrupted and end with touchcancel instead of touchend in scenarios such as:
When touchcancel occurred without proper handling:
Solution
Added handleTouchCancel function that performs comprehensive cleanup:
1. Touch Tracking Cleanup
2. Drag State Management
3. Gesture State Reset
When all touches are cancelled:
When some touches remain but less than 2:
Changes
src/hooks/useTrackpadGesture.ts
src/components/Trackpad/TouchArea.tsx
src/components/Trackpad/ScreenMirror.tsx
Testing Scenarios
This fix handles:
Technical Details
The implementation follows the same pattern as handleTouchEnd but with more aggressive cleanup since touchcancel indicates an abnormal termination. Unlike touchend, we do not attempt to interpret the gesture as a tap/click - we simply ensure all state is safely reset.
Impact
Significantly improves mobile UX reliability by:
Related Issues
Closes #75
Notes
This PR builds on PR #323 which added cleanup for draggingTimeout on unmount. Together, these changes ensure comprehensive lifecycle management for gesture state.