react / react/react-native

Padding on Text results in incorrect bounding box for press events

Đang mở
#54,056 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Issue: Author Provided Repro Platform: Android Platform: iOS Resolution: PR Submitted
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

When adding padding to a <Text /> element, onPress event are caught in the padding area on iOS rather than the text itself.

On Android, the text is clickable, but so is the padding area.

This happens with new architecture enabled.

Steps to reproduce
  1. Open the provided expo snack
  2. Click above the "Click me!" text
  3. Alert should come up
  4. Click the "Click me!" text
  5. This time no alert comes up
React Native Version

0.81.4

Affected Platforms

Runtime - iOS, Runtime - Android

Output of npx @react-native-community/cli info
System:
  OS: macOS 15.6.1
  CPU: (14) arm64 Apple M4 Pro
  Memory: 169.70 MB / 48.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.19.0
    path: ~/.nvm/versions/node/v22.19.0/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v22.19.0/bin/yarn
  npm:
    version: 10.9.3
    path: ~/.nvm/versions/node/v22.19.0/bin/npm
  Watchman:
    version: 2025.09.01.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods: Not Found
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.0
      - iOS 18.0
      - macOS 15.0
      - tvOS 18.0
      - visionOS 2.0
      - watchOS 11.0
  Android SDK:
    API Levels:
      - "29"
      - "30"
      - "31"
      - "34"
      - "35"
      - "36"
    Build Tools:
      - 34.0.0
      - 35.0.0
      - 36.0.0
      - 36.1.0
    System Images:
      - android-30 | Google APIs ARM 64 v8a
      - android-36 | Google Play ARM 64 v8a
    Android NDK: 29.0.14033849-beta4
IDEs:
  Android Studio: 2025.1 AI-251.26094.121.2513.14007798
  Xcode:
    version: 16.0/16A242d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.16
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /Users/giuseppebarillari/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.81.4
    wanted: 0.81.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found
Stacktrace or Logs
None
MANDATORY Reproducer

https://snack.expo.dev/@joe2k01/text-onpress-padding-bounding-box

Screenshots and Videos

https://github.com/user-attachments/assets/c50f9f2e-c80d-4fb0-9ad2-04073c7d38d8

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với Expo Snack bắt buộc và tái hiện hành vi hit testing của padding bằng kiến trúc mới trên cả iOS và Android. Sau đó, lần theo cách React Native Text xử lý press và cách tính bounding box cho các nền tảng bị ảnh hưởng. Công việc được xem là hoàn tất khi các lần chạm vào padding không kích hoạt press, trong khi các lần chạm vào văn bản vẫn kích hoạt press, với kiểm thử hồi quy cho cả hai nền tảng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
android, ios, react-native
Lĩnh vực
mobile-dev
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.