Fix whilePressing interaction getting stuck on multi-touch drag#2410
Open
Fix whilePressing interaction getting stuck on multi-touch drag#2410
Conversation
This commit addresses a bug where a button with a whilePressing prototyping interaction remains stuck in its pressed variant if multiple fingers are held down and dragged before being released. The issue stems from how Jetpack Compose handles multi-pointer gesture cancellations in the tryAwaitRelease() coroutine. By encapsulating the cleanup steps—specifically emitting the PressInteraction.Cancel or PressInteraction.Release and undoing the 'on press' reactions—within a finally block inside the onPress handler of detectTapGestures, we guarantee that regardless of how the touch gesture terminates (e.g., standard release or pointer cancellation from dragging multiple fingers), the UI correctly resets.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2410 +/- ##
=========================================
Coverage 44.05% 44.05%
Complexity 19 19
=========================================
Files 39 39
Lines 4444 4444
Branches 51 51
=========================================
Hits 1958 1958
Misses 2472 2472
Partials 14 14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Snapshot diff report vs base branch: main |
dipenpradhan
approved these changes
Apr 9, 2026
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.
Fixes a bug where a button with a whilePressing prototyping interaction remains stuck in its pressed variant if multiple fingers are held down and dragged before being released.
The issue stems from how Jetpack Compose handles multi-pointer gesture cancellations in the
tryAwaitRelease()coroutine. By encapsulating the cleanup steps—specifically emitting thePressInteraction.CancelorPressInteraction.Releaseand undoing the 'on press' reactions—within afinallyblock inside theonPresshandler ofdetectTapGestures, we guarantee that regardless of how the touch gesture terminates (e.g., standard release or pointer cancellation from dragging multiple fingers), the UI correctly resets.