Skip to content

Commit 8c4f240

Browse files
NickGerlemancortinico
authored andcommitted
Gate off % border radii on Android Paper (#45945)
Summary: Pull Request resolved: #45945 This code is forked on iOS, where we have been, as a policy, avoiding Paper-specific changes. This code is shared between renderers on Android, but it is confusing developer experience to have it work on Android Paper, to then fail on iOS unless it is on new arch. This change disables support on Android Paper for consistency. Changelog: [Android][Removed] - Gate off % border radii on Android Paper Reviewed By: cortinico Differential Revision: D60967347 fbshipit-source-id: 1d26bc71aee677aa9a0dc9bb38f781a99c7762a8
1 parent b64f549 commit 8c4f240

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4219,6 +4219,7 @@ public final class com/facebook/react/uimanager/LengthPercentage {
42194219
public static final field Companion Lcom/facebook/react/uimanager/LengthPercentage$Companion;
42204220
public fun <init> ()V
42214221
public fun <init> (FLcom/facebook/react/uimanager/LengthPercentageType;)V
4222+
public final fun getUnit ()Lcom/facebook/react/uimanager/LengthPercentageType;
42224223
public final fun resolve (FF)F
42234224
public static final fun setFromDynamic (Lcom/facebook/react/bridge/Dynamic;)Lcom/facebook/react/uimanager/LengthPercentage;
42244225
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/LengthPercentage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public enum class LengthPercentageType {
2020

2121
public class LengthPercentage(
2222
private val value: Float,
23-
private val unit: LengthPercentageType,
23+
public val unit: LengthPercentageType,
2424
) {
2525
public companion object {
2626
@JvmStatic

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.facebook.react.common.annotations.VisibleForTesting;
2424
import com.facebook.react.module.annotations.ReactModule;
2525
import com.facebook.react.uimanager.LengthPercentage;
26+
import com.facebook.react.uimanager.LengthPercentageType;
2627
import com.facebook.react.uimanager.PixelUtil;
2728
import com.facebook.react.uimanager.PointerEvents;
2829
import com.facebook.react.uimanager.Spacing;
@@ -131,9 +132,16 @@ public void nextFocusUp(ReactViewGroup view, int viewId) {
131132
ViewProps.BORDER_START_START_RADIUS,
132133
})
133134
public void setBorderRadius(ReactViewGroup view, int index, Dynamic rawBorderRadius) {
134-
135135
@Nullable LengthPercentage borderRadius = LengthPercentage.setFromDynamic(rawBorderRadius);
136136

137+
// We do not support percentage border radii on Paper in order to be consistent with iOS (to
138+
// avoid developer surprise if it works on one platform but not another).
139+
if (ViewUtil.getUIManagerType(view) != UIManagerType.FABRIC
140+
&& borderRadius != null
141+
&& borderRadius.getUnit() == LengthPercentageType.PERCENT) {
142+
borderRadius = null;
143+
}
144+
137145
view.setBorderRadius(BorderRadiusProp.values()[index], borderRadius);
138146
}
139147

0 commit comments

Comments
 (0)