Shopify / react-native-skia

High-performance React Native Graphics using Skia
https://shopify.github.io/react-native-skia
MIT License
6.97k stars 450 forks source link

pointerEvents="none" on <Canvas /> not working on android? #2551

Open vinayaksaubhri opened 3 months ago

vinayaksaubhri commented 3 months ago

Description

on Android when I have the Canvas as an overlay using StyleSheet.absoluteFill and I set the prop pointerEvents="none" then I still can not select any buttons below the Canvas overlay, as if the Canvas is still capturing the events, it works perfectly on iOS.

Version

1.2.3

Steps to reproduce

use the Canvas element as an overlay to a View with buttons using absolute positioning and then set the pointerEvents to none, the buttons would still not be pressable on Android.

Snack, code example, screenshot, or link to a repository

If I have an overlay component like so:

function Overlay() {
  const {height, width} = useWindowDimensions();

  return (
    <Canvas style={StyleSheet.absoluteFill} pointerEvents="none">
      <Rect height={height} width={width} color="red" opacity={0.5} />
    </Canvas>
  );
}

And I have Screen component like so:

function SomeScreen() {
    return (
        <>
            <View style={{flex: 1}}>
                <Button title="navigate" onPress={() => { console.log('I have been tapped') }} />
            </View>
            <Overlay />
        </>
    )
}

I would not be able to select the button on Android.

mvaivre commented 2 months ago

This issue was reported in the past, but I can confirm that it's happening today with 1.2.3.

ugar0ff commented 1 month ago

Same, checked on "@shopify/react-native-skia": "1.3.11", "@shopify/react-native-skia": "1.3.13", and "react-native": "0.74.5",

ugar0ff commented 1 month ago

I found solution, need to wrap Canvas in View with pointerEvents="none"

    <View
      pointerEvents="none"
      style={styles.shadowContainer>
      <Canvas pointerEvents="none">
muneerlalji commented 1 month ago

Any updates on this issue? I'm having the same problem and would like to move away from the workaround above

vinayaksaubhri commented 1 week ago

I found solution, need to wrap Canvas in View with pointerEvents="none"

    <View
      pointerEvents="none"
      style={styles.shadowContainer>
      <Canvas pointerEvents="none">

This will not work for me as I want to wrap the entire home screen in canvas for a animation