Repository navigation
Conversation
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
There was a problem hiding this comment.
🟡 Changes recommended
Hard-coding native-gesture handling to false in the public InterceptingGestureDetector can cause enclosing ScrollViews to dismiss the keyboard after handled native-control taps; the opt-out should be limited to the ScrollView wrapper.
1 open issue
What changed in this PR
This PR simplifies v3 gesture responder handling by removing SharedValue listeners and relying on touch-time enabled reads, reducing detector state and re-renders.
Changes:
- Removes listener bookkeeping and the unused
getEnabledSharedValueshelper; uses a stable no-op outside responder context. - Consolidates the intercepting detector and changes its native gestures to never mark taps as handled.
- Adds coverage for SharedValue changes without re-rendering and updates intercepting-detector expectations.
| File | Description |
|---|---|
packages/react-native-gesture-handler/src/v3/hooks/utils/reanimatedUtils.ts |
Removes the unused SharedValue collection helper. |
packages/react-native-gesture-handler/src/v3/hooks/useJSResponderHandler.ts |
Removes listeners and simplifies the responder callback. |
packages/react-native-gesture-handler/src/v3/detectors/VirtualDetector/InterceptingGestureDetector.tsx |
Consolidates the detector and disables native-gesture marking. |
packages/react-native-gesture-handler/src/v3/createNativeWrapper.tsx |
Adjusts detector selection and responder-option forwarding. |
packages/react-native-gesture-handler/src/v3/components/GestureComponents.web.tsx |
Removes the explicit ScrollView opt-out argument. |
packages/react-native-gesture-handler/src/v3/components/GestureComponents.tsx |
Removes the explicit ScrollView opt-out argument. |
packages/react-native-gesture-handler/src/__tests__/jsResponderHandler.test.tsx |
Tests touch-time reads of changing SharedValue state. |
packages/react-native-gesture-handler/src/__tests__/api_v3.test.tsx |
Updates native-gesture responder expectations. |
Review effort: Balanced
| const { handleStartShouldSetResponder } = useJSResponderHandler( | ||
| gesture, | ||
| countNativeAsHandled | ||
| false |
There was a problem hiding this comment.
Out of scope for this PR (the line comes from #4530), and intentional there. On main InterceptingGestureDetector never marked taps, so this isn't a regression. We tried counting its Native gesture by default and it kept the keyboard open on every tap on pagers wrapped in an InterceptingGestureDetector (verified on Android and iOS), with no way for users to opt out. Its Native gesture belongs to the container hosting virtual children; native tap targets should use GestureDetector, which still marks them.
…sponder-drop-enabled-listener

Description
#4158 added a SharedValue listener to
useJSResponderHandler: whenever a SharedValue passed asenabledchanged, it bumped a state counter so that the responder handler was re-created. The handler readsenabledwhen the touch starts (maybeUnpackValuereturns.value), and it already did so when the listener was added, so the counter never changed the result. It only cost a state, a ref and an effect with UI-thread scheduling for every detector, plus a re-render of the detector on every flip.This PR removes the listener and the now unused
getEnabledSharedValues. The hook is now a context read and a single callback, and without aScrollViewabove it returns a stable no-op instead of a new function on every render. This also applies toNativeDetector, which has run the listener since #4158.Test plan
enabledwithout a re-render and checks that the marking follows it. It fails ifenabledis evaluated during render.Pressable,TouchableanduseTapGesture: press with the keyboard open, then a tap on the blank area,enabledflipped from JS and from the UI thread: disabled closes the keyboard and the tap doesn't fire, enabled keeps the keyboard open and the tap fires.Tested on the following code: