react / react/react-native

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

未关闭
#56,879 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Component: ScrollView Needs: Triage :mag: Platform: Android Platform: iOS
主要语言
C++
星标
127k
派生
25.3k
平均合并
1 天 23 小时
30 天内合并 PR
4

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先在 iOS 上运行 https://github.com/birdofpreyru/rn-scroll-view-bug 中的必需复现程序,并反复滚动 Pressable 内的 ScrollView。跟踪 iOS 对 Pressable 和 ScrollView 的触摸处理,然后验证滚动是否能够可靠地开始,同时 Pressable 仍能处理 ScrollView 外部的点击。

由索引模型根据 Issue 内容生成。

评估

技术栈
ios, react-native
领域
mobile
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。