Fix tapHold event firing during table scroll on touch devices#4892
Open
rathboma wants to merge 2 commits into
Open
Fix tapHold event firing during table scroll on touch devices#4892rathboma wants to merge 2 commits into
rathboma wants to merge 2 commits into
Conversation
Add a failing unit test demonstrating that a pending tapHold timer is not cancelled when the table is scrolled. clearTouchWatchers() nulls the watcher references but never clears the underlying setTimeout, so the 1000ms tapHold callback still fires after a scroll and dispatches rowTapHold, opening the row context menu mid-scroll on touch devices.
clearTouchWatchers() nulled the watcher references but never cleared the underlying timers, so a tapHold timer armed by a touchstart would still fire ~1s after the user started scrolling, dispatching rowTapHold and opening the row context menu mid-scroll on touch devices. Call clearTimeout() on each watcher before nulling it so scrolling properly cancels the in-flight tap/tapHold gesture.
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.
Summary
This PR fixes an issue where the
tapHoldevent would incorrectly fire when scrolling a table on touch devices, causing unwanted context menus to appear mid-scroll.Key Changes
clearTimeout()call inclearTouchWatchers()method to properly cancel pending tapHold timers before nullifying themImplementation Details
The fix addresses issue #4482 by ensuring that when
clearTouchWatchers()is called (which happens during scroll events), any pending tapHold timeout is explicitly cancelled viaclearTimeout()before the reference is set to null. This prevents the timeout callback from executing after the user has already started scrolling, which would have been a scroll gesture rather than a hold gesture.The test replicates the exact scenario: a touchstart event initiates a tapHold timer, then scrolling triggers
clearTouchWatchers(), and the test verifies that the tapHold event is never dispatched even after the original 1000ms timeout elapses.https://claude.ai/code/session_01Y2aoGEPqTv8USRzMe27uHq