Repository navigation
Stop a gesture area's swipe also pressing a pressable on Android - #182
Merged
Merged
Conversation
… tap Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…droid Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
On Android, swiping across a pressable inside a
native:gesture-areafires both the area's@swipeand the pressable's@press. The same goes for a pressable around the area. iOS only fires the swipe, because a tap there fails once the touch moves. Found in NativePHP/dev-null-app#102, where swiping a long message bubble opened its actions and the same gesture's tap closed them again.Cause
The swipe's
pointerInputinGestureAreaRenderer.ktadds up the pan without consuming anything. Compose'sclickableonly cancels a tap when the pointer leaves its bounds or a change is consumed. A horizontal swipe that ends inside the bubble is neither, so the tap goes through on release.Fix
Once the pan passes touch slop with the swipe's finger count, the swipe looks at the Final pass of that event. If nothing has consumed it yet, the swipe takes the drag and consumes every change for the rest of the gesture.
@swipestill fires when something else owns the drag, as before, since the swipe adds up the pan whether or not a change was consumed.Worth a look
pan-xand gets a vertical swipe (orpan-yand a horizontal one) now keeps that gesture for the swipe, so the pan doesn't move during it. A swipe along the bound axis is unchanged, since the pan drag takes it first.Tests
tests/androidgetsGestureAreaSwipeTest, six Robolectric cases: one-finger and two-finger swipes over a pressable inside the area, a swipe inside a pressable around the area, a plain tap, a vertical drag in averticalScroll, and an area with a boundpan-x. The three swipe-over-pressable cases fail onmainwithpressevents next to the swipe, and all six pass here. The existing 12 focused-input cases still pass.The module now also stages
GestureAreaRenderer.ktand core'sSharedValueStore.kt, and has a smallNodeViewstand-in that draws each child as a box, clickable like a corepressable.On a device
Android emulator (API 35), a test screen in the dev-null app with a gesture area around a long pressable bubble, a pressable around a gesture area and a two-finger area, all in a
scroll-view. Two-finger swipes were injected as real two-pointer touch events.mainiOS isn't touched.
Once this is tagged, dev-null-app can drop
Conversation::SwipeTapWindow, its 0.75 s workaround.🤖 Generated with Claude Code