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

BaseButton ripple covered by child <Image /> #544

Closed
chhornponleu opened this issue Apr 1, 2019 · 4 comments · Fixed by #1981
Closed

BaseButton ripple covered by child <Image /> #544

chhornponleu opened this issue Apr 1, 2019 · 4 comments · Fixed by #1981
Labels
Bug BugBash 31.03 Close when stale The issue will be closed automatically if it remains inactive Platform: Android This issue is specific to Android

Comments

@chhornponleu
Copy link

Issue:

BaseButton ripple works fine with Text as child, but not with Image.

To reproduce:

<BaseButton style={{height: 150, width: 100}}>
   <Image source={...} style={{width: 100, height: 100}}/>
</BaseButton>

"react-native-gesture-handler": "^1.0.16",
"react": "16.8.3",
"react-native": "0.59.1",

Tested Device: Samsung Galaxy S6, Android 7.0

@eyousefifar
Copy link

You can use the absolute filling as a workaround, wrap button and image in a view and style button with absolute fill, btw I have to specify rippleColor too or I get some weird behavior.

@TheWirv
Copy link
Contributor

TheWirv commented Jun 21, 2019

This is why RN's TouchableNativeFeedback component has the useForeground prop. RNGH's three button components should imitate this behavior.

The "absolute filling" workaround doesn't work for me, btw.

@jakub-gonet jakub-gonet changed the title (Android) BaseButton ripple covered by child <Image /> BaseButton ripple covered by child <Image /> Aug 21, 2020
@jakub-gonet jakub-gonet added Platform: Android This issue is specific to Android Bug labels Aug 21, 2020
@jkadamczyk jkadamczyk removed the Platform: Android This issue is specific to Android label Aug 21, 2020
@jakub-gonet jakub-gonet added the Platform: Android This issue is specific to Android label Aug 21, 2020
@liran
Copy link

liran commented Aug 28, 2020

Wrap Ripple.js

import React from 'react';
import { View, StyleSheet } from 'react-native';
import { RectButton } from 'react-native-gesture-handler';

const styles = StyleSheet.create({
  box: {
    position: 'relative',
  },
  ripple: {
    position: 'absolute',
    left: 0,
    top: 0,
    width: '100%',
    height: '100%',
    zIndex: 1,
  },
});

export default ({ style, children, ...props }) => {
  return (
    <View style={[style, styles.box]}>
      {children}
      <RectButton rippleColor="#888" style={styles.ripple} {...props} />
    </View>
  );
};

@j-piasecki
Copy link
Member

Hi! Adding foreground prop to the BaseButton should fix the problem. I'm not sure why it's not present in the types for it, but it will work nonetheless. I'll update the types for it soon.

@j-piasecki j-piasecki added the Close when stale The issue will be closed automatically if it remains inactive label Mar 31, 2022
j-piasecki added a commit that referenced this issue Apr 4, 2022
Fixes #544.

Some Android-only props were missing from `BaseButton` type: `rippleRadius`, `borderless` and `foreground`. This PR adds them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug BugBash 31.03 Close when stale The issue will be closed automatically if it remains inactive Platform: Android This issue is specific to Android
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants