software-mansion / react-native-gesture-handler

Declarative API exposing platform native touch and gesture system to React Native.
https://docs.swmansion.com/react-native-gesture-handler/
MIT License
6.13k stars 982 forks source link

Button components have incorrect layout when given padding on iOS new arch #3100

Closed brentvatne closed 2 months ago

brentvatne commented 2 months ago

Description

Expand to see source App.js for the following examples ```js import { StyleSheet, TouchableOpacity, Text, View } from "react-native"; import { GestureHandlerRootView, BorderlessButton, RectButton } from "react-native-gesture-handler"; function BrokenBorderlessButtonPadding() { return ( { }} style={styles.buttonStyles} > Hi, this is an RNGH BorderlessButton ); } function BrokenRectButtonPadding() { return ( { }} style={styles.buttonStyles} > Hi, this is an RNGH RectButton ); } function WorkingButtonPadding() { return ( { }} style={styles.buttonStyles} > Hi, this is a TouchableOpacity with identical styling ); } export default function App() { return ( ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: "#fff", alignItems: "center", justifyContent: "center", }, buttonStyles: { paddingHorizontal: 30, paddingVertical: 30, backgroundColor: "#ccc", borderBottomWidth: 2, borderBottomColor: 'green' } }); ```

New arch

Screenshot 2024-09-13 at 2 53 44 PM

Old arch

Screenshot 2024-09-13 at 3 14 05 PM

Steps to reproduce

Or more simply in your own app, create a button and add some vertical padding to it. Notice that the bottom padding isn't being applied correctly. Example styles: https://github.com/brentvatne/rngh-button-padding-new-arch/blob/75652daff3e48ae77c200ea867e71f7f527dfebc/App.js#L59-L65

Snack or a link to a repository

https://github.com/brentvatne/rngh-button-padding-new-arch

Gesture Handler version

2.19.0

React Native version

0.75.3

Platforms

iOS

JavaScript runtime

Hermes

Workflow

Expo bare workflow

Architecture

Fabric (New Architecture)

Build type

Debug mode

Device

iOS simulator

Device model

iPhone 15 (iOS 17.5)

Acknowledgements

Yes

brentvatne commented 2 months ago

A workaround for now is to add a vertical margin to a child view instead of padding on the button

alexkuttig commented 2 months ago

Thanks @j-piasecki for the fix. Is there any plan, when this will be released as 2.9.1 or so?