[Web] Assign role for Native gesture in detector#4130
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a web-specific mechanism to tag “Native” gesture targets with a semantic role so NativeViewGestureHandler can apply role-dependent behavior when used via v3 Native/Virtual detectors.
Changes:
- Introduces
NativeGestureRoleplus arngh-roleDOM attribute constant for role tagging on web. - Updates
HostGestureDetector.webandVirtualDetectorto set the role attribute based on the wrapped child’sdisplayName. - Refactors
NativeViewGestureHandlerto use a singlerolefield (instead ofbuttonRole/switchRole) and to read the role from the new attribute for detector-based paths.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-gesture-handler/src/web/interfaces.ts | Adds NativeGestureRole enum. |
| packages/react-native-gesture-handler/src/web/constants.ts | Adds NATIVE_GESTURE_ROLE_ATTRIBUTE (rngh-role). |
| packages/react-native-gesture-handler/src/web/handlers/GestureHandler.ts | Makes actionType protected for subclass access. |
| packages/react-native-gesture-handler/src/web/handlers/NativeViewGestureHandler.ts | Reads role from rngh-role for detector paths; consolidates role handling. |
| packages/react-native-gesture-handler/src/v3/detectors/HostGestureDetector.web.tsx | Sets rngh-role on the native-detector child element based on displayName. |
| packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/VirtualDetector.tsx | Attempts to set rngh-role for virtual-detector children on web. |
| packages/react-native-gesture-handler/src/components/GestureHandlerButton.web.tsx | Sets ButtonComponent.displayName = 'Button' to enable role inference. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
j-piasecki
reviewed
May 4, 2026
j-piasecki
reviewed
May 6, 2026
j-piasecki
approved these changes
May 7, 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.
Description
In this PR I change how the role is assigned to
Nativegesture. Previously we relied on different checks, likehasAttributeandquerySelector. In this PR I changed it so that Detector usesdisplayNameto determine underlying component.I've also removed double
hitSlopassignment (289c922)Test plan
Tested on the following example: