Skip to content

scale 0 touchable is clickable, inherits dimensions from random views #50797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vanaigr opened this issue Apr 18, 2025 · 6 comments
Open

scale 0 touchable is clickable, inherits dimensions from random views #50797

vanaigr opened this issue Apr 18, 2025 · 6 comments

Comments

@vanaigr
Copy link

vanaigr commented Apr 18, 2025

Description

If a transform scaleY: 0 is applied to a view with e.g. TouchableWithoutFeedback inside, the clicks are still registered as if TouchableWithoutFeedback had some height.

The height matches height of another TouchableWithoutFeedback in the hierarchy.

Steps to reproduce

  1. Connect an Android device.
  2. git clone https://github.com/vanaigr/react-native-scale-0-bug and cd into the directory
  3. npm i
  4. npm run android
  5. Wait until the app is started on the device
  6. From Metro, open DevTools
  7. On the phone, change Scale: input to 0.5
  8. Click within 50% from the center of the green rectangle. Observe message 1 clicked appears in console.
  9. Click outide 50% from the center of the green rectangle. Observe no additional messages are printed.
  10. Change Scale: input to 0.9
  11. Click outide 50%, but within 90% from the center of the green rectangle. Observe message 1 clicked printed in console.
  12. Change Scale: input to 0
  13. Click near the middle of the blue rectangle. Observe message 2 clicked printed in console.

React Native Version

0.79.0

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info

System:
  OS: Windows 10 10.0.19045
  CPU: "(12) x64 AMD Ryzen 5 4500 6-Core Processor              "
  Memory: 5.91 GB / 15.87 GB
Binaries:
  Node:
    version: 20.16.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn: Not Found
  npm:
    version: 10.8.2
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: Not Found
  Visual Studio:
    - 17.9.34723.18 (Visual Studio Community 2022)
Languages:
  Java: 17.0.13
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 18.0.0
    wanted: 18.0.0
  react:
    installed: 19.0.0
    wanted: 19.0.0
  react-native:
    installed: 0.79.0
    wanted: 0.79.0
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

N/A

Reproducer

https://github.com/vanaigr/react-native-scale-0-bug

Screenshots and Videos

2025-04-18.00-04-30.mp4
@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - 0.79.1. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@react-native-bot
Copy link
Collaborator

Tip

Newer version available: You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@vanaigr
Copy link
Author

vanaigr commented Apr 18, 2025

Reproducible on 0.79.1

@vanaigr
Copy link
Author

vanaigr commented Apr 18, 2025

Similar (but different) behavior is present in 0.76.9

@vanaigr vanaigr changed the title scale 0 touchable inherits dimensions from random views scale 0 touchable is clickable, inherits dimensions from random views Apr 18, 2025
@cipolleschi
Copy link
Contributor

@vanaigr thanks for the issue. We will look into it as soon as possible.

I believe this is the reproducer, am I correct?

import { AppRegistry } from 'react-native';
import { name as appName } from './app.json'
import React from 'react'
import { View, Text, TouchableWithoutFeedback, TextInput } from 'react-native'

function App() {
    const [value, setValue] = React.useState('0.9')
    const [scale, setScale] = React.useState(0.9)

    return <View>
        <View style={{ backgroundColor: 'green', marginTop: 50 }}>
            <View style={{ height: 200, transform: [{ scaleY: 0 }] }}>
                <TouchableWithoutFeedback onPress={() => console.log('1 clicked')}>
                    <View style={{ flex: 1, backgroundColor: 'red' }}>
                        <Text>View 1</Text>
                    </View>
                </TouchableWithoutFeedback>
            </View>
        </View>
        <View style={{ backgroundColor: 'blue', marginTop: 50 }}>
            <View style={{ height: 200, transform: [{ scaleY: scale }] }}>
                <TouchableWithoutFeedback onPress={() => console.log('2 clicked')}>
                    <View style={{ flex: 1, backgroundColor: 'red' }}>
                        <Text>View 2</Text>
                    </View>
                </TouchableWithoutFeedback>
            </View>
        </View>
        <View>
            <Text>Scale:</Text>
            <TextInput value={value} onChangeText={it => {
                setValue(it)
                const p = parseFloat(it)
                if(isFinite(p)) setScale(p)
            }}/>
        </View>
    </View>
}

AppRegistry.registerComponent(appName, () => App);

@vanaigr
Copy link
Author

vanaigr commented Apr 22, 2025

I believe this is the reproducer, am I correct?

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants