Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the GestureStateManager.begin() API (v3) and tightens manual activation behavior so gestures cannot be activated unless they have already transitioned into BEGAN (i.e., received touches / began recognition).
Changes:
- Remove
begin()from the v3GestureStateManagerAPI (native + web implementations). - Stop forcing
UNDETERMINED -> BEGAN -> ACTIVEin manual activation flows (web/iOS/Android). - Prevent
GestureHandler.activate()on web from transitioning fromUNDETERMINEDtoACTIVE.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-gesture-handler/src/web/handlers/GestureHandler.ts | Disallows activation unless the handler is already in BEGAN. |
| packages/react-native-gesture-handler/src/v3/gestureStateManager.web.ts | Removes begin() and stops auto-begin in activate() for web v3. |
| packages/react-native-gesture-handler/src/v3/gestureStateManager.ts | Removes begin() from the exported v3 state manager type/impl. |
| packages/react-native-gesture-handler/apple/RNGestureHandlerModule.mm | Blocks ACTIVE state changes for handlers that never left UNDETERMINED. |
| packages/react-native-gesture-handler/apple/RNGestureHandler.h | Exposes lastState for the new activation guard; formatting changes. |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt | Blocks UNDETERMINED -> ACTIVE and adjusts when handlers get recorded. |
Comments suppressed due to low confidence (1)
packages/react-native-gesture-handler/src/v3/gestureStateManager.web.ts:25
GestureStateManager.activatealways callsGestureHandlerOrchestrator.instance.recordHandlerIfNotPresent(handler)even whenhandler.activate(true)will no-op (e.g. when the handler is stillUNDETERMINED). Since the web orchestrator only cleans upEND/FAILED/CANCELLEDhandlers, this can leave anUNDETERMINEDhandler permanently recorded, causing an orchestrator list leak and extra processing. Consider checkinghandler.state === State.BEGANbefore recording/activating (or otherwise avoid recording when activation is ignored).
const handler = NodeManager.getHandler(handlerTag);
ensureHandlerAttached(handler);
GestureHandlerOrchestrator.instance.recordHandlerIfNotPresent(handler);
handler.activate(true);
},
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...e-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt
Outdated
Show resolved
Hide resolved
Contributor
Author
|
This PR intentionally breaks current StateManager example, I'm trying to think of a good replacement, if you have any ideas, let me know. |
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.
Description
We realised that there is no real use case for allowing to state manage gestures which did not receive touches. Thus we decided to remove the function
GestureStateManager.begin()altogether, as if gesture had received touches it's state is set to begun. Additonally StateManager will no longer force going through begin state in activate, thus if we attempt to use state manager to activate a non begun gesture it won't activate.Test plan
Tested on the following example
Details