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

Hover style is not applied correctly to Pressable components #12

Closed
okwasniewski opened this issue Oct 20, 2023 · 6 comments
Closed

Hover style is not applied correctly to Pressable components #12

okwasniewski opened this issue Oct 20, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@okwasniewski
Copy link
Member

okwasniewski commented Oct 20, 2023

Description

Hover style is not applied correctly to Pressable components. For some reason, Pressable components are not passing borderRadius to the native side correctly.

CleanShot 2023-10-20 at 12 19 12@2x

@okwasniewski okwasniewski added the bug Something isn't working label Oct 20, 2023
@Aakashdeep-Srivastava
Copy link

let's do this.... Assign me

@Marcoo09
Copy link

Hi @okwasniewski, I was not able to reproduce it. It was solved?

@okwasniewski
Copy link
Member Author

Hey @Marcoo09,

No it wasn't fixed. If you go to Components > Pressable and modify ContentPress function like so:

function ContentPress() {
  const [timesPressed, setTimesPressed] = useState(0);

  let textLog = '';
  if (timesPressed > 1) {
    textLog = timesPressed + 'x onPress';
  } else if (timesPressed > 0) {
    textLog = 'onPress';
  }

  return (
    <>
      <View style={styles.row}>
        <Pressable
+          style={{padding: 10, borderRadius: 20, backgroundColor: 'red'}}
          onPress={() => {
            setTimesPressed(current => current + 1);
          }}>
          {({pressed}) => (
            <Text testID="one_press_me_button" style={styles.text}>
              {pressed ? 'Pressed!' : 'Press Me'}
            </Text>
          )}
        </Pressable>
      </View>
      <View style={styles.logBox}>
        <Text testID="pressable_press_console">{textLog}</Text>
      </View>
    </>
  );
}

You will see that borderRadius is not correctly applied for hoverStyle

CleanShot 2023-12-12 at 10 22 41@2x

@gokul1099
Copy link

gokul1099 commented Dec 14, 2023

I gone through this issue, In RCTViewComponentView.cpp, self.layers.cornerRadius becomes 0.0. because of that *shape is created with 0 borderRadius.

image

If we pass any custom value like
UIShape *shape = [UIShape rectShapeWithCornerRadius: CGFloat(20)]; it is working fine
@okwasniewski Do you have any idea on this ?

@okwasniewski
Copy link
Member Author

@gokul1099 Maybe we need to use RCTCornerRadiiFromBorderRadii / track where layer.cornerRadius is set back to 0. I think this is a bug somewhere deep in RN

@gokul1099
Copy link

gokul1099 commented Dec 15, 2023

I gone through this issue, In RCTViewComponentView.cpp, self.layers.cornerRadius becomes 0.0. because of that *shape is created with 0 borderRadius.

image If we pass any custom value like ` UIShape *shape = [UIShape rectShapeWithCornerRadius: CGFloat(20)];` it is working fine @okwasniewski Do you have any idea on this ?

I have found something. whenever we update the borderRadius the updateHoverEffect is not getting triggered. So I made some changes like below so it will get triggered everytime props changes. After this change the borderRadius working fine.
(only if we change the props borderRadius value)
image
screenshot after above changes ->
image

But in the initial render the self.layers.cornerRadius in updateHoverEffect is 0.0. So the borderRadius is not getting applied.
@okwasniewski Can we send the borderRadius as parameter from newViewProps to updateHoverEffect like the hoverEffect string we are passing updateHoverEffect:[NSString stringWithUTF8String:newViewProps.visionos_hoverEffect.c_str()] ??

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

4 participants