[Android] Tapping a Text with a `VirtualGestureDetector` inside a `Touchable` presses the `Touchable` instead when the Text overflows its detector
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 22/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ệ
- android, kotlin, typescript
- Lĩnh vực
- mobile
Hướng nghiên cứu
Start in GestureHandlerOrchestrator.kt, at recordViewHandlersForPointer, and compare the order it records ancestor handlers (extractAncestorHandlers) against virtual child handlers in the overflow case. ButtonViewGroup.shouldBeginWithRecordedHandlers is where the Touchable begins without seeing the nested Tap. Done means case A in the reproduction logs A: link pressed on Android, while cases B and C still pass.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
If you have the following structure:
Touchable
\_ InterceptingGestureDetector around Text
\_ VirtualGestureDetector around Text + useTapGesture
tapping the inner text (i.e. the virtual detector) triggers the Touchable onPress, not the tap gesture.
This only happens if the text has sub-pixel translate applied to it (look at reproduction for reference).
AI explanation:
GestureHandlerOrchestrator.recordViewHandlersForPointer (3.5.0, L626) records handlers for a view in this order:
- handlers attached to the view itself,
- if the view overflows its parent: handlers of all ancestors (
extractAncestorHandlers, L672-L683), - if the view is a
ReactCompoundView: handlers of the virtual child under the pointer, i.e. the nestedText(L685-L709).
Virtual children are descendants of the view, but in the overflow case they are recorded after its ancestors. The ancestor Touchable's NativeViewGestureHandler is therefore recorded first, ButtonViewGroup.shouldBeginWithRecordedHandlers sees no recorded descendant handler (recorded=[]), and the button begins. On ACTION_UP it activates and makeActive cancels the Tap of the nested text.
When the view does not overflow, the regular traversal records children before parents, so the button sees the Tap and yields — that's why case B below works.
The overflow itself comes from pixel rounding. RNGestureHandlerDetectorShadowNode widens the detector's frame on Android to cover its transformed child (extend(frame * transform)), but the detector and the Text are rounded to pixels independently, so a sub-pixel translateY can leave the Text a fraction of a pixel outside the detector. Frames from dumpsys activity top for case A on a 2.0-density emulator (translateY: -0.7 = -1.4px):
ButtonViewGroup 40,428-960,519 (920x91)
RNGestureHandlerDetectorView 0,-1-920,91 (920x92)
ReactTextView 0,1-920,92 translationY=-1.4 -> effective top = -0.4 => isViewOverflowingParent == true
Case B (no transform) is 0,0-920,91 all the way down.
Native logging of the ACTION_DOWN in case A (handler tags shortened):
record NativeViewGestureHandler view=ButtonViewGroup recorded=[] begin=true
record NativeViewGestureHandler view=ReactScrollView recorded=[Button] begin=true
record TapGestureHandler view=ReactTextView recorded=[Button, ScrollView, ...] begin=true
---- ACTION_UP
state NativeViewGestureHandler(Button) BEGAN -> ACTIVE
makeActive NativeViewGestureHandler(Button)
state TapGestureHandler BEGAN -> CANCELLED (GestureHandlerOrchestrator.makeActive)
Steps to reproduce
- Render the component below on Android (new architecture).
- Tap "this link" in each of the three paragraphs.
Expected: every tap logs <case>: link pressed.
Actual:
| Case | Setup | Tapping the link logs |
|---|---|---|
| A | Touchable > Text with translateY: -0.7 |
A: Touchable pressed (link never fires) |
| B | Touchable > Text, no transform |
B: link pressed |
| C | plain View > Text with translateY: -0.7 |
C: link pressed |
Whether it reproduces depends on how the transform rounds at the device's density. We used -0.7 on a density 2.0 (320 dpi) emulator. An integer value like -2 does not reproduce, because the widened detector frame absorbs it exactly.
import { useState } from 'react';
import { Text, View } from 'react-native';
import {
GestureHandlerRootView,
InterceptingGestureDetector,
Touchable,
useTapGesture,
VirtualGestureDetector,
} from 'react-native-gesture-handler';
function Link({ onPress }: { onPress: () => void }) {
const tap = useTapGesture({ disableReanimated: true, onActivate: onPress });
return (
<VirtualGestureDetector gesture={tap}>
<Text style={{ color: 'dodgerblue' }}>this link</Text>
</VirtualGestureDetector>
);
}
function Paragraph({
name,
translateY,
log,
}: {
name: string;
translateY?: number;
log: (message: string) => void;
}) {
return (
<InterceptingGestureDetector>
<Text
style={{
fontSize: 18,
transform: translateY ? [{ translateY }] : undefined,
}}>
{name}: tap <Link onPress={() => log(`${name}: link pressed`)} /> in
the middle of the text.
</Text>
</InterceptingGestureDetector>
);
}
export default function App() {
const [events, setEvents] = useState<string[]>([]);
const log = (message: string) =>
setEvents((previous) => [message, ...previous].slice(0, 6));
return (
<GestureHandlerRootView style={{ flex: 1, padding: 20, paddingTop: 80, gap: 24 }}>
<View style={{ height: 110 }}>
{events.map((event, index) => (
<Text key={index} style={{ color: 'gray' }}>
{event}
</Text>
))}
</View>
<Touchable onPress={() => log('A: Touchable pressed')}>
<Paragraph name="A" translateY={-0.7} log={log} />
</Touchable>
<Touchable onPress={() => log('B: Touchable pressed')}>
<Paragraph name="B" log={log} />
</Touchable>
<View>
<Paragraph name="C" translateY={-0.7} log={log} />
</View>
</GestureHandlerRootView>
);
}
A link to a Gist, an Expo Snack or a link to a repository based on this template that reproduces the bug.
Gesture Handler version
3.5.0
React Native version
0.86.3
Platforms
Android
JavaScript runtime
None
Workflow
None
Build type
None
Device
Android emulator
Device model
No response
Acknowledgements
Yes
- Ngôn ngữ chính
- TypeScript
- Star
- 6.8k
- Fork
- 1.1k
- Merge trung bình
- 2 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 28
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
-
GestureDetector should bubble touches if all gestures fail (or some other generalized solution)Đang mởMissing repro Platform: Android Platform: iOS
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 39/100
software-mansion/react-native-gesture-handler#4714 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Web] A pan that starts on a Pressable presses it when the mouse button is releasedCó thể đã có người làm @mokshupadhyay đã nhận 1 ngày trước. Đang mởPlatform: Web
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 57/100
software-mansion/react-native-gesture-handler#4713 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[iOS] Crash at app exit: static `_managers` map destroyed while `flushOperations` reads itCó thể đã có người làm @beqramo đã nhận 5 ngày trước. Đang mởMissing info Missing repro Platform: iOS Platform: MacOS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 30/100
software-mansion/react-native-gesture-handler#4711 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[iOS][Fabric] Recognizer of a live handler stays on a recycled view and takes every drag on the component that reuses itCó thể đã có người làm @nihar777 đã nhận 5 ngày trước. Đang mởPlatform: iOS
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
software-mansion/react-native-gesture-handler#4710 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[iOS] Button press feedback invisible on quick taps when Reduce Motion is enabledCó thể đã có người làm @andreialecu đã nhận 7 ngày trước. Đang mởMissing info Platform: iOS Platform: MacOS
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
software-mansion/react-native-gesture-handler#4707 · 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 68/100
ehmpathy/rhachet-roles-bhrain#878 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Chat UI: Message actions dropdown is cut off beneath composer when message is near bottom of chatCó thể đã có người làm @koeria đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
milind-soni/OpenMausBot#8023 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Windows microphone listing treats words in a device name as DirectShow labelsCó thể đã có người làm @Sujal-chaudhary đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
clipy-recorder/clipy#447 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement from-app needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
nightly-labs/openbot#19162 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
triage:in-progress
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Cotal-AI/Cotal#11229 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày