Skip to content

pointerEvents={'none'} does not work on Android #25644

Closed

Description

@arlovip

Bug

I try to use pointerEvents={'none'} on Image component, but it does not work on Android. It is effective on iOS.

React Native version:

 React Native Environment Info:
    System:
      OS: macOS 10.14.5
      CPU: (4) x64 Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
      Memory: 141.91 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 12.1.0 - /usr/local/bin/node
      Yarn: 1.16.0 - /usr/local/bin/yarn
      npm: 6.9.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        API Levels: 24, 26, 27, 28
        Build Tools: 26.0.2, 27.0.3, 28.0.2, 28.0.3
        System Images: android-24 | Google APIs Intel x86 Atom, android-27 | Intel x86 Atom_64, android-28 | Intel x86 Atom_64
    IDEs:
      Android Studio: 3.0 AI-171.4443003
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.9 => 0.59.9 
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7

Steps To Reproduce

export default class GeneralBackground extends PureComponent {

    render() {
        return (
            <View style={styles.container}>
                {this.props.children}
                <Image
                    source={myImage}
                    style={styles.image}
                    pointerEvents={'none'} // Does not work on Android.
                />
            </View>
        );
    }

}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: Colors.theme
    },
    image: {
        width: 160,
        resizeMode: 'stretch',
        alignSelf: 'center',
        position: 'absolute'
    }
});

I expect that this.props.children like Button component can be work but not Image above. But it can work on iOS via testing, Android failed. Did I use it by mistake? I think it maybe a bug.
Anybody knows that? Thanks a lot in advance.

Activity

  1. RobinCsl commented on Jul 14, 2019

    @RobinCsl

    Hi @Amos729,

    It seems that the pointerEvents prop is not available on the Image component: searching pointerEvents on https://facebook.github.io/react-native/docs/image yielded nothing.

    I believe it's only available for View components: https://facebook.github.io/react-native/docs/view#pointerevents

    Doing something like that

    <View style={styles2.image} pointerEvents={'none'}> 
       <Image source={myImage} />
    </View>
    

    made a children Button clickable on Android.

    Hope that helps!

  2. arlovip commented on Jul 14, 2019

    @arlovip
    Author

    @RobinCsl I tried what you said just now. It's really useful both Android and iOS platform.
    Thank you so much.

  3. jjercx commented on Mar 11, 2021

    @jjercx

    For the record, same problem with TextInput but also solved with a wrapping view with pointerEvents={'none'}

  4. locked as resolved and limited conversation to collaborators on Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions