9

I have a TouchableOpacity inside of a view. The view is small (height: 60) and the TouchableOpacity lies outside the bounds of its parent (position: absolute, top: 70). When the child is inside of the parent, i.e. top: 30, it's clickable, but when it's outside, it's not. And only the regions inside of the parent view are clickable (touch events pass through the regions out of bounds). Does anyone know of a way to register TouchableOpacity clicks even when it's outside the bounds of its parent?

Note that this works on iOS. It seems to only be a bug on android.

<View style={{height: 60, width: '100%', zIndex: 1}}> <TouchableOpacity onPress={() => console.log('pressed')} style={{position: 'absolute', zIndex: 2, backgroundColor: 'yellow', width: 100, height: 50, top: 70}} /> </View> 
4
  • have you tried setting elevation:1? Android generally ignores zIndex Commented Nov 12, 2019 at 20:02
  • 1
    @MikeM Thanks for the suggestion! I just tried it, but still not working :/ Commented Nov 12, 2019 at 21:47
  • 4
    Did you find a solution to this? I'm having a similar problem Commented Jan 10, 2020 at 12:15
  • 1
    Same issue here as well. Commented Feb 22, 2020 at 15:02

1 Answer 1

1

The best workaround so far is to

import { TouchableOpacity } from 'react-native-gesture-handler'; 

Solution was found here.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.