iOS: selectable Text edit menu flickers on long-press release (handleLongPress ignores gesture.state)
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C++
- Star
- 127k
- Fork
- 25.3k
- Merge trung bình
- 1 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 4
Mô tả
Description
On iOS 16+ (New Architecture), long-pressing a <Text selectable> shows the edit menu ("Copy"), and the moment the finger is lifted the menu animates out and immediately back in. It is a ~100 ms blink on every release, on every selectable Text.
Cause: RCTParagraphComponentView.handleLongPress: does not check gesture.state. A UILongPressGestureRecognizer fires its action on Began and again on Ended (and on Changed when the finger moves). The second call re-runs [_editMenuInteraction presentEditMenuWithConfiguration:], and UIKit dismisses the presented menu before presenting the new one.
- (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
{
if (@available(iOS 16.0, macCatalyst 16.0, *)) {
CGPoint location = [gesture locationInView:self];
UIEditMenuConfiguration *config = [UIEditMenuConfiguration configurationWithIdentifier:nil sourcePoint:location];
if (_editMenuInteraction) {
[_editMenuInteraction presentEditMenuWithConfiguration:config];
}
} else {
// the legacy branch is guarded by `menuController.isMenuVisible`; the iOS 16 branch is not
Fix (verified, see below):
- (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
{
if (gesture.state != UIGestureRecognizerStateBegan) {
return;
}
...
Happy to open a PR if that helps.
Steps to reproduce
- Render
<Text selectable>Some text</Text>in any screen (New Architecture, iOS 16+). - Long-press the text until "Copy" appears.
- Lift the finger.
Expected: the menu stays. Actual: the menu disappears and reappears at touch-up.
Evidence: screen recording of the simulator at 20 fps, OCR of each frame for "Copy" (C = menu visible, . = not):
before: ....CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC..CCCCCCCCCCCCCCCCCCCCCCC....
after: ....CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC....
The gap in the first line is the release (Maestro longPressOn, ~3 s hold). The second line is the same scenario with the one-line guard compiled in (built from source, ios.buildReactNativeFromSource in Expo).
React Native Version
0.86.2 (code unchanged in 0.87.0)
Affected Platforms
Runtime - iOS
Output of npx @react-native-community/cli info
System: macOS 26.2
Xcode: 26.4
iOS Simulator: iPhone 17 Pro
react-native: 0.86.2 (Expo SDK 57), New Architecture, Hermes
Stacktrace or Logs
n/a (visual)
MANDATORY Reproducer
Any <Text selectable> on iOS 16+ with the New Architecture reproduces it; the bug is fully explained by the source above (the action handler is invoked for every gesture state).
Screenshots and Videos
Frame-by-frame OCR trace above.
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.
Hướng nghiên cứu
Mở packages/react-native/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm và kiểm tra handleLongPress:. Tái hiện thao tác nhấn giữ trên Text có thể chọn trong iOS 16+ với New Architecture, sau đó xác minh rằng menu chỉnh sửa vẫn hiển thị sau khi thả ra mà không bị nhấp nháy.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- ios, objective-c, react-native
- Lĩnh vực
- mobile
- Loại issue
- Lỗi
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 88/100