Skip to content
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

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

Open
vinayaksaubhri opened this issue Jul 27, 2024 · 7 comments
Open

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

vinayaksaubhri opened this issue Jul 27, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@vinayaksaubhri
Copy link

vinayaksaubhri commented Jul 27, 2024

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.

@vinayaksaubhri vinayaksaubhri added the bug Something isn't working label Jul 27, 2024
@mvaivre
Copy link

mvaivre commented Aug 19, 2024

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

mvaivre added a commit to alephium/alephium-frontend that referenced this issue Aug 19, 2024
Issue: pointerEvents non not working on Android
cf: Shopify/react-native-skia#2551
mvaivre added a commit to alephium/alephium-frontend that referenced this issue Aug 23, 2024
Issue: pointerEvents non not working on Android
cf: Shopify/react-native-skia#2551
mvaivre added a commit to alephium/alephium-frontend that referenced this issue Sep 3, 2024
Issue: pointerEvents non not working on Android
cf: Shopify/react-native-skia#2551
mvaivre added a commit to alephium/alephium-frontend that referenced this issue Sep 3, 2024
Issue: pointerEvents non not working on Android
cf: Shopify/react-native-skia#2551
mvaivre added a commit to alephium/alephium-frontend that referenced this issue Sep 3, 2024
Issue: pointerEvents non not working on Android
cf: Shopify/react-native-skia#2551
mvaivre added a commit to alephium/alephium-frontend that referenced this issue Sep 4, 2024
Issue: pointerEvents non not working on Android
cf: Shopify/react-native-skia#2551
mvaivre added a commit to alephium/alephium-frontend that referenced this issue Sep 4, 2024
Issue: pointerEvents non not working on Android
cf: Shopify/react-native-skia#2551
mvaivre added a commit to alephium/alephium-frontend that referenced this issue Sep 5, 2024
Issue: pointerEvents non not working on Android
cf: Shopify/react-native-skia#2551
mvaivre added a commit to alephium/alephium-frontend that referenced this issue Sep 9, 2024
Issue: pointerEvents non not working on Android
cf: Shopify/react-native-skia#2551
@ugar0ff
Copy link

ugar0ff commented Sep 26, 2024

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

@ugar0ff
Copy link

ugar0ff commented Sep 27, 2024

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

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

@muneerlalji
Copy link

muneerlalji commented Oct 15, 2024

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

@vinayaksaubhri
Copy link
Author

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

@KuryshchukNazar2004
Copy link

@vinayaksaubhri Tell me if you found a solution to the problem?

@ivanloy
Copy link

ivanloy commented Dec 18, 2024

@vinayaksaubhri With a similar use case, it works if you make the parent view also cover the whole screen.

<View pointerEvents="none" style={styles.fullScreenContainer}>
    <Canvas pointerEvents="box-none" style={styles.fullScreenContainer} onLayout={setContainerDimensions}>
        <Atlas image={texture} sprites={sprites} transforms={transforms} />
    </Canvas>
</View>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants