react / react/react-native

Pressables don't prevent touches being forwarded to OS

Offen
#56,061 2 Kommentare 15 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Needs: Triage :mag: p: Callstack Partner
Vorherrschende Sprache
C++
Sterne
127k
Forks
25.3k
Ø Merge
1 T. 23 Std.
Gemergte PRs (30 T.)
4

Beschreibung

Description

React Native pressables don't seem to prevent the touches from being forwarded to the OS. This results in unexpected behavior in some situations.

e.g. on iPadOS, there is a large area at the top of the screen that can be tapped to scroll to the top. This area usually covers a similar height to the header bar. If headers have buttons that use pressables, the pressable handles the action, but iPadOS also handles the touch and scrolls any scrollview in the screen to the top.

This does not happen when using a native control (e.g., with UIControl), and only happens with React Native's Pressable. It is very common to add custom buttons to the header (even when using native stack and native header), many people also use custom headers. So the unexpected scroll to top results in a bad UX.

I'm not aware of a way to prevent this behavior right now.

Steps to reproduce
  1. Install the app on iPad simulator with yarn ios
  2. Scroll the scrollview so it's not at the top
  3. Click on the button in the header
  4. Observe that the button also scrolls the scrollview to the top
React Native Version

0.84.1

Affected Platforms

Runtime - iOS

Output of npx @react-native-community/cli info
System:
  OS: macOS 26.3
  CPU: (14) arm64 Apple M4 Pro
  Memory: 119.75 MB / 48.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 24.13.0
    path: /Users/satya/.local/state/fnm_multishells/2979_1773239105373/bin/node
  Yarn:
    version: 1.22.22
    path: /opt/homebrew/bin/yarn
  npm:
    version: 11.6.2
    path: /Users/satya/.local/state/fnm_multishells/2979_1773239105373/bin/npm
  Watchman:
    version: 2025.10.13.00
    path: /run/current-system/sw/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.2
      - iOS 26.2
      - macOS 26.2
      - tvOS 26.2
      - visionOS 26.2
      - watchOS 26.2
  Android SDK:
    API Levels:
      - "28"
      - "29"
      - "30"
      - "31"
      - "32"
      - "33"
      - "35"
      - "36"
      - "36"
    Build Tools:
      - 28.0.3
      - 29.0.2
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 32.0.0
      - 33.0.0
      - 33.0.1
      - 34.0.0
      - 35.0.0
      - 35.0.0
      - 36.0.0
    System Images:
      - android-24 | Google APIs ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
      - android-36.1 | Pre-Release 16 KB Page Size Google APIs ARM 64 v8a
      - android-36 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2025.3 AI-253.30387.90.2532.14935130
  Xcode:
    version: 26.2/17C52
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.8.1
    path: /opt/homebrew/opt/sdkman-cli/libexec/candidates/java/current/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.1.0
    wanted: 20.1.0
  react:
    installed: 19.2.3
    wanted: 19.2.3
  react-native:
    installed: 0.84.1
    wanted: 0.84.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
Stacktrace or Logs
NA
MANDATORY Reproducer

https://github.com/satya164/iPadTouchableRepro

Screenshots and Videos

https://github.com/user-attachments/assets/d81dcc82-ddf7-4c0b-82f1-f4bdb70ad798

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem obligatorischen Reproducer unter https://github.com/satya164/iPadTouchableRepro und reproduziere das im Issue beschriebene iPadOS-Verhalten. Verfolge anschließend die iOS-Touch-Behandlung von Pressable. Es wird keine Quelldatei und kein Test genannt; abgeschlossen ist die Arbeit, wenn das Aktivieren eines Pressable nicht mehr zusätzlich das iPadOS-Scroll-to-top-Verhalten auslöst, während native Steuerelemente weiterhin unbeeinträchtigt bleiben.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
react-native
Bereich
mobile
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.