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

Nested buttons press event #44

Open
flahtorres opened this issue Jul 15, 2022 · 3 comments
Open

Nested buttons press event #44

flahtorres opened this issue Jul 15, 2022 · 3 comments

Comments

@flahtorres
Copy link

flahtorres commented Jul 15, 2022

I have a custom component that have to buttons using Ripple, a button act like a container and another to only icon. Both the container and icon have distincts press events, but when I a click in the icon, only the container is trigerted and a the icon press event is never called.

Here is the code

<Ripple onPress={event1}>
    <View>
        <Text>Primary click handler</Text>
        {/* antoher view elemets */}

        <Ripple onPress={event2}>
            <View>
                <Icon />
            </View>
        </Ripple>
    </View>
</Ripple>

When I click in the text, the "event1" is called and I see the ripple in all container.
When I click in the Icon, the"event1" is called too and I see the ripple in all container instead of only in Icon
The "event2" is never called and I never see their ripple

This doesn't happened when I tried to render with react-native TouchableOppacity instead of Ripple

Obs: the Icon element is a implementation of react-native-vector-icons, I tried change the icon to a text and I have the same issue

React-Native: 0.68.2
React-Native-Material-Ripple: 0.9.1
I am testing on Android Studio emulator

@rivaslive
Copy link

Set view with xIndex: -1 or 0.
This happens because the view is above the element, the zIndex could make it position below, or you can use Ripple as an absolute that takes 100% of the height and width, I think you could try both approaches, good luck!

@badaz
Copy link

badaz commented Nov 2, 2022

I'm facing same problem: react-native 0.70.4. I updated from 0.67 where problem did not exist. Unfortunately, this lib does not seem to be maintained anymore, last commit is from 2019.

@MaiconGilton
Copy link

I fixed by removing pointerEvents='box-only' in Animated.View https://github.com/n4kz/react-native-material-ripple/blob/39ea61e8345feaa8086899f1a2e90ef31ce422bf/index.js#L267.

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

No branches or pull requests

4 participants