react-native-paper icon indicating copy to clipboard operation
react-native-paper copied to clipboard

Button and IconButton TouchableRipple borderRadius is calculated from the icon size and not the button borderRadius

Open jahirfiquitiva opened this issue 1 year ago • 3 comments

Current behaviour

The IconButton component TouchableRipple borderRadius is calculated based on the icon size and the button padding.

https://github.com/callstack/react-native-paper/blob/8e5d12da0685fc5073fd930d4043131b1c472f8b/src/components/IconButton/IconButton.tsx#L150-L155

https://github.com/callstack/react-native-paper/blob/8e5d12da0685fc5073fd930d4043131b1c472f8b/src/components/IconButton/IconButton.tsx#L186

Expected behaviour

The borderRadius for the TouchableRipple should match the borderRadius set for the button in styles and fill the button surface

How to reproduce?

https://snack.expo.dev/@jahirfiquitiva/rnp-iconbutton-ripple

Preview

Shot 2024-01-11 at 12 10 10@2x

Alternative solution

Add a prop to customize the TouchableRipple borderRadius.

jahirfiquitiva avatar Jan 11 '24 17:01 jahirfiquitiva

I have updated the expo example to show the same issue with the Button component.

I have set a bigger padding and the TouchableRipple does not fill the Button surface

Shot 2024-01-11 at 12 28 45@2x

Edit:

This one can be fixed using contentStyle instead of style but I kinda feel it's not so intuitive to do so

jahirfiquitiva avatar Jan 11 '24 17:01 jahirfiquitiva

Hey @jahirfiquitiva, would you like to investigate the problem and propose the solution?

lukewalczak avatar Jan 14 '24 13:01 lukewalczak

@lukewalczak I have opened the PR #4278 which should fix the issues and provide alternatives for the things that cannot be easily fixed

jahirfiquitiva avatar Jan 16 '24 01:01 jahirfiquitiva