fix: dragging stops after a screen is detached and re-attached (gesture-handler v3)#573
Draft
MatiPl01 wants to merge 7 commits into
Draft
fix: dragging stops after a screen is detached and re-attached (gesture-handler v3)#573MatiPl01 wants to merge 7 commits into
MatiPl01 wants to merge 7 commits into
Conversation
Drags could get stuck or stop starting after a screen was detached and re-attached on iOS + New Architecture (e.g. bottom tabs with detachInactiveScreens=false) - a gesture-handler v2 limitation (#349). The new gesture-handler integration uses the v3 hook API when installed and falls back to the v2 imperative builder otherwise, selected once at module load. Non-breaking: the peer range stays >=2.0.0 and public types use only gesture names exported by both majors.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Remove the as-unknown-as double casts (centralize gesture bridging in a single asSortableGesture helper plus narrowing casts) and trim the adapter comments to the non-obvious rationale only. No behavior change.
react-native-sortables is built against gesture-handler v3, so importing it in the example app's jest tests pulled in an unmocked v3 native module (RNGestureHandlerModule getEnforcing). Map every gesture-handler import to the single mocked instance the app already sets up.
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
On iOS + the New Architecture, a sortable could stop recognizing drags - the dragged item gets "stuck", or a drag won't start - after its screen was detached and re-attached, for example bottom tabs with
detachInactiveScreens={false}. This is issue #349.The root cause is an upstream react-native-gesture-handler v2 limitation: after react-native-screens re-attaches the screen, the v2
GestureDetectorloses its touch stream, so a drag never receives its touch-up/cancel and never ends. The gesture-handler team confirmed the v2 API can't be fixed for this and resolved it in the v3 hook API (see react-native-gesture-handler#3560).Fix
A small backward-compatible gesture-handler integration (
src/integrations/gesture-handler) that uses the v3 hook API (useManualGesture/useTapGesture/ ...) when gesture-handler v3 is installed - which fixes #349 - and falls back to the existing v2 imperative builder otherwise. The version is detected once at module load, so the right gesture path is chosen without any runtime branching inside hooks:Not a breaking change: the peer range stays
>=2.0.0and the public types use only gesture names exported by both majors. The issue is New-Architecture-only; the Old Architecture (Paper) keeps the v2 path, where it never occurs and which gesture-handler v3 no longer supports.Recording (iOS, New Architecture, gesture-handler v3)
Drag reorders an item, switch to the other tab and back, then drag again: it keeps working (this is where v2 would get stuck).
Closes #349