react / react/react-native

[iOS] `<ScrollView>` struggles inside a `<Pressable>` (while it works just fine on Android)

Aperta
#56,879 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Component: ScrollView Needs: Triage :mag: Platform: Android Platform: iOS
Lingua principale
C++
Stelle
127k
Fork
25.3k
Merge medio
1g 23h
PR unite (30g)
4

Descrizione

Description

Render

<Pressable>
  <ScrollView>
    <Text>Anything tall, worth to scroll through... e.g. 10 paragraphs of Lorem Ipsum</Text>
  </ScrollView>
</Pressable>

if you try repeatedly to scroll it on iOS, either on Simulator, or on a real device (tested with iPhone), sometimes it will scroll normally, but half of the time it won't start scrolling on your tap, like if there is an interference between the parent Pressable and the ScrollView. If you turn that Pressable into just a boring View you'll find the scrolling works just fine.

At the same time, on Android it works just fine:

  • ScrollView scrolls alright
  • Pressable captures (if you add it onPress handler) on taps outside ScrollView

In other words, on Android it works as if the ScrollView is above the parent Pressable in the view stack when handling touches; and on iOS it works as they are at the same level of the stack, intercepting user touches randomly, one or another.

P.S.: Yeah, I know there is a workaround to render the same like

<>
  <Pressable>...</Pressable>
  <ScrollView>...</ScrollView>
</>

which works, but I don't see why the problematic variant should not work as well.

Steps to reproduce

Just run the repro app and play with the scrolling.

React Native Version

0.85.3

Affected Platforms

Runtime - iOS

Output of npx @react-native-community/cli info
info Fetching system and libraries information...
System:
  OS: macOS 26.5
  CPU: (12) arm64 Apple M3 Pro
  Memory: 253.81 MB / 18.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 24.15.0
    path: /Users/sergey_pogodin/.nvm/versions/node/v24.15.0/bin/node
  Yarn:
    version: 1.22.22
    path: /Users/sergey_pogodin/.nvm/versions/node/v24.15.0/bin/yarn
  npm:
    version: 11.12.1
    path: /Users/sergey_pogodin/.nvm/versions/node/v24.15.0/bin/npm
  Watchman:
    version: 2024.12.02.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.5
      - iOS 26.5
      - macOS 26.5
      - tvOS 26.5
      - visionOS 26.5
      - watchOS 26.5
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 26.5/17F42
    path: /usr/bin/xcodebuild
Languages:
  Java: Not Found
  Ruby:
    version: 3.4.1
    path: /opt/homebrew/opt/ruby/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.85.3
    wanted: 0.85.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
Stacktrace or Logs
N/A
MANDATORY Reproducer

https://github.com/birdofpreyru/rn-scroll-view-bug

Screenshots and Videos

No response

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia eseguendo il riproduttore obbligatorio all’indirizzo https://github.com/birdofpreyru/rn-scroll-view-bug su iOS e scorrendo ripetutamente nella ScrollView all’interno di Pressable. Traccia la gestione del tocco di iOS per Pressable e ScrollView, quindi verifica che lo scorrimento inizi in modo affidabile mentre Pressable continua a gestire i tap al di fuori della ScrollView.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
ios, react-native
Ambito
mobile
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.