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

Children with negative margins yield unexpected behavior

Open Tatious opened this issue 4 years ago • 3 comments

Steps to Reproduce

Create a view with a child that has a negative margin:

<View style={{ paddingLeft: 100, paddingTop: 200 }}>
  <View style={{ width: 200, height: 40, backgroundColor: 'green', borderRadius: 4 }}>
    <View
      style={{
        position: 'absolute',
        top: 0,
        bottom: 0,
        left: 0,
        right: 0,
        borderWidth: 2,
        borderRadius: 10,
        borderColor: 'white',
        margin: -6,
      }}
    />
  </View>
</View>

Expected Behavior

In this case, there is a border around the parent (iOS): IMG_0527

Actual Behavior

The child view does not show: (Windows): Screen Shot 2020-05-11 at 1 08 13 PM

Additional context

Adam Gorman(adamgor) Austin Beaulieu(aubeauli)

Tatious avatar May 11 '20 20:05 Tatious

May be a clipping issue?

chrisglein avatar May 14 '20 18:05 chrisglein

Is there any headway or information with this? I am also running into this issue.

CarpeDiEmma avatar Sep 20 '21 23:09 CarpeDiEmma

Yes, this is a clipping issue caused by use of negative margins. We are still experiencing this problem and it does cause problems for several desired scenarios. Especially focus rects for buttons.

[updated] After one of our dev's did an investigation, the issue is actually caused by setting a border radius on the button, without a border radius, the focus rect shows, setting a border radius causes anything with a negative margin to clip, regardless of whether overflow is set to hidden or visible.

This is a workaround: <View style={{ justifyContent: "center", alignItems: "center", width: 200, height: 40, overflow: "visible", }} > <View style={{ borderWidth: 2, borderRadius: 10, borderColor: "white", padding: 4, }} > <View style={{ width: 200, height: 40, backgroundColor: "green", borderRadius: 4, }} /> </View> </View>

HansHugli avatar Jun 21 '22 17:06 HansHugli

Will not be an added feature for RNW on Paper. Will flag issue to make sure this behavior is supported on Fabric.

chiaramooney avatar Aug 10 '23 23:08 chiaramooney