some TouchableOpacity isn't working on IOS 0.76
未关闭
还没有人认领这个 Issue。
Component: TouchableOpacity
Issue: Author Provided Repro
Platform: iOS
Resolution: PR Submitted
Type: New Architecture
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 4
描述
Description
After upgrading from 0.73 to 0.76, I found that some TouchableOpacity could not be clicked, so I made a minimize buggy demo code, which just depend on react-native, no 3rd libs
Steps to reproduce
- npx @react-native-community/cli@latest init TouchableOpacityDemo
- cd ios && bundle exec pod install
- modify App.tsx
import * as React from "react";
import {
StyleSheet,
TouchableOpacity,
ScrollView,
Alert,
View,
Text,
Image,
} from "react-native";
const styles = StyleSheet.create({
text: {
color: "#FFF",
fontSize: 16,
},
icons: {
display: "flex",
flexDirection: "row",
justifyContent: "space-evenly",
paddingVertical: 5,
alignSelf: "stretch",
backgroundColor: "#FFF",
},
title: { fontSize: 18, flexWrap: "wrap", color: "#000" },
});
const App = ({ }) => {
return (
<ScrollView
style={{ flex: 1, backgroundColor: '#808000' }}
contentContainerStyle={{
flexDirection: "row",
flexWrap: "wrap",
justifyContent: "space-evenly",
}}
>
<View
style={{
width: 150,
display: "flex",
justifyContent: "space-between",
alignItems: "center",
marginTop: 10,
}}
>
<TouchableOpacity style={{ width: 150, height: "100%", backgroundColor: '#CC0' }} onPress={() => {
Alert.alert('cover click');
}}>
<Image source={{ uri: 'https://placehold.jp/3d4070/ffffff/150x150.png' }} style={{ height: 150 }} />
</TouchableOpacity>
<View style={styles.icons}>
<TouchableOpacity style={{ width: 20, height: "100%", backgroundColor: '#C00' }} onPress={() => {
Alert.alert('A click');
}}><Text>A</Text></TouchableOpacity>
<TouchableOpacity style={{ width: 20, height: "100%", backgroundColor: '#C00' }} onPress={() => {
Alert.alert('B click');
}}><Text>B</Text></TouchableOpacity>
<TouchableOpacity style={{ width: 20, height: "100%", backgroundColor: '#C00' }} onPress={() => {
Alert.alert('C click');
}}><Text>C</Text></TouchableOpacity>
</View>
</View>
</ScrollView>
);
};
export default App;
- yarn ios
- you can see the image can click but the buttons A/B/C can not click
- if change
height: "100%"toheight: 150in line 47 the buttons A/B/C can click again
React Native Version
0.76.6
Affected Platforms
Runtime - iOS
Output of npx react-native info
System:
OS: macOS 15.2
CPU: (10) arm64 Apple M4
Memory: 139.52 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 22.11.0
path: ~/.nvm/versions/node/v22.11.0/bin/node
Yarn:
version: 4.6.0
path: ~/.nvm/versions/node/v22.11.0/bin/yarn
npm:
version: 10.9.0
path: ~/.nvm/versions/node/v22.11.0/bin/npm
Watchman:
version: 2024.12.02.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /opt/homebrew/lib/ruby/gems/3.4.0/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.2
- iOS 18.2
- macOS 15.2
- tvOS 18.2
- visionOS 2.2
- watchOS 11.2
Android SDK: Not Found
IDEs:
Android Studio: 2024.2 AI-242.23726.103.2422.12816248
Xcode:
version: 16.2/16C5032a
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.10
path: /Users/iwater/.sdkman/candidates/java/current/bin/javac
Ruby:
version: 3.4.1
path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 15.0.1
wanted: 15.0.1
react:
installed: 18.3.1
wanted: 18.3.1
react-native:
installed: 0.76.6
wanted: 0.76.6
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
Stacktrace or Logs
no
Reproducer
https://github.com/iwater/TouchableOpacityDemo
Screenshots and Videos
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 App.tsx reproducer 开始,重点关注 ScrollView 内嵌套的 TouchableOpacity 组件以及 height: "100%" 样式。在 iOS 上运行列出的 setup 和 yarn ios,然后将行为与 height: 150 进行比较;当 A、B 和 C 按钮能够响应按下操作且不会破坏图像按钮时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- ios, react-native, typescript
- 领域
- mobile
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100