Centralize gesture state reset logic in useTrackpadGesture#286
Centralize gesture state reset logic in useTrackpadGesture#286Shashank-Mengani wants to merge 2 commits intoAOSSIE-Org:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughIntroduces a centralized Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/hooks/useTrackpadGesture.ts`:
- Around line 58-61: resetGestureState currently unconditionally clears the
pending left-click timeout (draggingTimeout.current), which cancels the deferred
mouse-up scheduled in handleTouchEnd and causes tap/drag state to break; change
resetGestureState (or its callers) so it does not clear draggingTimeout.current
by default — either add a boolean parameter (e.g., preserveLeftClickTimeout) or
split out a separate clearTimers function and only clear draggingTimeout.current
when you really want to cancel the pending left-click; update calls from
handleTouchEnd/anywhere that need to preserve the deferred mouse-up to call
resetGestureState(..., preserveLeftClickTimeout=true) or call the new split
function accordingly, keeping references to draggingTimeout.current in those
places (symbols: resetGestureState, handleTouchEnd, draggingTimeout.current).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: eca455e8-2754-4176-9667-f729d2e20f33
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (1)
src/hooks/useTrackpadGesture.ts
…ken tap/drag gestures
|
Currently I Updated the code and initial commit and push it
…On Wed, 11 Mar, 2026, 20:34 coderabbitai[bot], ***@***.***> wrote:
***@***.***[bot]* requested changes on this pull request.
*Actionable comments posted: 1*
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In ***@***.***/hooks/useTrackpadGesture.ts`:
- Around line 58-61: resetGestureState currently unconditionally clears the
pending left-click timeout (draggingTimeout.current), which cancels the deferred
mouse-up scheduled in handleTouchEnd and causes tap/drag state to break; change
resetGestureState (or its callers) so it does not clear draggingTimeout.current
by default — either add a boolean parameter (e.g., preserveLeftClickTimeout) or
split out a separate clearTimers function and only clear draggingTimeout.current
when you really want to cancel the pending left-click; update calls from
handleTouchEnd/anywhere that need to preserve the deferred mouse-up to call
resetGestureState(..., preserveLeftClickTimeout=true) or call the new split
function accordingly, keeping references to draggingTimeout.current in those
places (symbols: resetGestureState, handleTouchEnd, draggingTimeout.current).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
------------------------------
ℹ️ Review info ⚙️ Run configuration
*Configuration used*: Path: .coderabbit.yaml
*Review profile*: ASSERTIVE
*Plan*: Pro
*Run ID*: eca455e8-2754-4176-9667-f729d2e20f33
📥 Commits
Reviewing files that changed from the base of the PR and between 3c85686
<3c85686>
and 161bd29
<161bd29>
.
⛔ Files ignored due to path filters (1)
- package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
- src/hooks/useTrackpadGesture.ts
------------------------------
In src/hooks/useTrackpadGesture.ts
<#286 (comment)>:
> + if (draggingTimeout.current) {
+ clearTimeout(draggingTimeout.current)
+ draggingTimeout.current = null
+ }
*
|
|
I only see added code and removed comments without reduction in redundancy |
…file
Addressed Issues:
Fixes #(281)
Description
This PR centralizes the gesture state reset logic inside the
useTrackpadGesturehook.Previously, gesture-related refs were reset in multiple places across the
hook, which made the code harder to maintain and increased the risk of
missing state variables when introducing new gesture states.
This change introduces a helper function
resetGestureState()thatconsolidates the reset logic for:
All gesture reset logic is now handled in one place, improving
maintainability and reducing duplicated code.
Screenshots/Recordings:
Not applicable — this PR only refactors internal gesture state logic
without changing UI or user-visible behavior.
Functional Verification
Screen Mirror
Authentication
Basic Gestures
One-finger tap: Verified as Left Click.
Two-finger tap: Verified as Right Click.
Click and drag: Verified selection behavior.
Pinch to zoom: Verified zoom functionality (if applicable).
Modes & Settings
Cursor mode: Cursor moves smoothly and accurately.
Scroll mode: Page scrolls as expected.
Sensitivity: Verified changes in cursor speed/sensitivity settings.
Copy and Paste: Verified both Copy and Paste functionality.
Invert Scrolling: Verified scroll direction toggles correctly.
Advanced Input
Key combinations: Verified "hold" behavior for modifiers (e.g., Ctrl+C) and held keys are shown in buffer.
Keyboard input: Verified Space, Backspace, and Enter keys work correctly.
Glide typing: Verified path drawing and text output.
Voice input: Verified speech-to-text functionality for full sentences.
Backspace doesn't send the previous input.
Any other gesture or input behavior introduced:
None. This PR does not introduce new gestures.
It only refactors internal state reset logic.
Additional Notes:
This change preserves the existing gesture behavior and only improves
code maintainability by centralizing gesture state reset logic.
Checklist
My PR addresses a single issue, fixes a single bug or makes a single improvement.
My code follows the project's code style and conventions
I have performed a self-review of my own code
I have commented my code, particularly in hard-to-understand areas
If applicable, I have made corresponding changes or additions to the documentation
If applicable, I have made corresponding changes or additions to tests
My changes generate no new warnings or errors
I have joined the and I will share a link to this PR with the project maintainers there
I have read the
Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
Incase of UI change I've added a demo video.
We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact.
Summary by CodeRabbit