Jest: with the hook API, raw touch events fired under a `GestureDetector` don't reach ancestors under Testing Library 14
Maintainer thường phản hồi trong vòng 2 ngày
@aliassar đang làm issue này rồi.
Từ ngày 2/11/2026.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 66/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react-native, typescript
Hướng nghiên cứu
Start with the Jest mock at src/mocks/hostDetector.tsx and the hook detector at src/v3/detectors/NativeDetector.tsx, then reproduce the failing case from the linked repository with npx jest. Check how the mock and detector interact with Testing Library 14's touch event handling. Done when the parent receives touchStart in Jest under a hook gesture and the builder API case still passes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
This happens only in Jest: it's an interaction between Gesture Handler 3's test stand-in and React Native Testing Library, not a bug in the runtime.
Under Jest, jestSetup.js replaces HostGestureDetector with a plain View (src/mocks/hostDetector.tsx at v3.3.0). For a hook gesture, NativeDetector passes that View its onStartShouldSetResponder (NativeDetector.tsx#L76 at v3.3.0), which declines the responder.
Testing Library 14 treats a declining responder as blocking every event for the ancestors above it, raw touch events included. So fireEvent(child, 'touchStart') under a hook gesture's GestureDetector no longer reaches a parent's onTouchStart. On a device it does. (Once a gesture activates on a device, the ancestors get touchCancel, as expected: that isn't what this is about. In Jest, touchStart and the moves before activation never reach them.) With a builder-API gesture, no such View is rendered and the touch gets through, so tests that passed on 2.x start failing after moving to the hooks.
The root cause appears to be on Testing Library's side: on a device, raw touch events reach every ancestor whatever the responder does, and Testing Library applies the responder rule to them anyway. I've reported it there as callstack/react-native-testing-library#1957. I'm raising it here too because Gesture Handler 3 users will run into it when they move tests from the builder API to the hooks, so you may want to do something about it on your side, or at least be aware of it.
Steps to reproduce
- Clone https://github.com/jrmsayag/rntl-touch-bubbling-repro-demo and run
npm ci. - Run
npx jest. - "with a hook-API gesture (usePanGesture())" fails: the parent's
onTouchStartgets 0 calls. "with a builder-API gesture (Gesture.Pan())" passes.
function Pannable() {
const gesture = usePanGesture({});
return (
<GestureDetector gesture={gesture}>
<View testID="child" />
</GestureDetector>
);
}
it('a raw touchStart under a hook gesture reaches the parent', async () => {
const onTouchStart = jest.fn();
await render(
<GestureHandlerRootView>
<View onTouchStart={onTouchStart}>
<Pannable />
</View>
</GestureHandlerRootView>,
);
await fireEvent(screen.getByTestId('child'), 'touchStart');
expect(onTouchStart).toHaveBeenCalledTimes(1); // fails: 0 calls
});
A link to a Gist, an Expo Snack or a link to a repository
https://github.com/jrmsayag/rntl-touch-bubbling-repro-demo
Gesture Handler version
3.3.0
React Native version
0.88.1
Platforms
Android, iOS (it happens in Jest, whatever the platform)
JavaScript runtime
Hermes (not relevant: Jest runs on Node)
Workflow
Using Expo Prebuild or an Expo development build (the repro itself is plain React Native with @react-native/jest-preset)
Build type
Debug mode
Device
Not applicable (Jest); pick any.
Device model
Not applicable (Jest, Node 22). @testing-library/react-native 14.1.0, Jest 30.5.2.
Acknowledgements
Yes
- Ngôn ngữ chính
- TypeScript
- Star
- 6.8k
- Fork
- 1.1k
- Merge trung bình
- 1 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 46
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của software-mansion/react-native-gesture-handler
-
[Jest][3.5.0] `fireEvent.press` no longer reaches `Touchable` when its child is inside an `InterceptingGestureDetector`Có thể đã có người làm @m-bert đã nhận 3 ngày trước. Đang mởMissing info Platform: Web
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
software-mansion/react-native-gesture-handler#4689 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Web] GestureDetector blocks context menu by defaultCó thể đã có người làm @lassiecoder đã nhận 4 ngày trước. Đang mởPlatform: Web
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 56/100
software-mansion/react-native-gesture-handler#4687 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Android] v3 `ReanimatedSwipeable` takes over a vertical scroll in a React Native list once the finger drifts 10 dp sidewaysCó thể làm lại được @JaydeepAgravat đã nhận 10 ngày trước và không có pull request nào đang mở. Đang mởPlatform: Android
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
software-mansion/react-native-gesture-handler#4670 · 6 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Android] A held tap on a Touchable or Pressable in ScrollView does nothing while the keyboard is upCó thể đã có người làm @m-bert đã nhận 6 ngày trước. Đang mởMissing repro Platform: Android
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 50/100
software-mansion/react-native-gesture-handler#4653 · 7 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[IOS] The "hitslop" attribute used in the packaging component FlatList does not work as expected.Đang mởClose when stale Missing repro Platform: iOS
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
software-mansion/react-native-gesture-handler#4649 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của software-mansion/react-native-gesture-handler
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
pollen-robotics/reachy-mini-desktop-app#341 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
mike-north/AgentMonitors#648 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Position: a popup placed again from between two layout steps lands a fraction of a pixel offĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
vercel-labs/ui#700 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 2 ngày