Skip to content

Commit 8d5bbca

Browse files
jorge-cabfacebook-github-bot
authored andcommitted
Fix borderRadius incorrect overrides (#44602)
Summary: Pull Request resolved: #44602 Fix regression caused by D56943825 where radii set to 0 was not being considered. Also preemptively fix a possible bug with RTL due to incorrect overrides. Changelog: [Android][Fixed] - Fix borderRadius incorrect overrides Reviewed By: NickGerleman Differential Revision: D57473482 fbshipit-source-id: d22a46bdd271d5f254e7d7e54abc55c00a8da8f2
1 parent 06e37bb commit 8d5bbca

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class LengthPercentage(
2828
return when (dynamic.getType()) {
2929
ReadableType.Number -> {
3030
val value = dynamic.asDouble()
31-
if (value > 0f) {
31+
if (value >= 0f) {
3232
LengthPercentage(PixelUtil.toPixelFromDIP(value), LengthPercentageType.POINT)
3333
} else {
3434
null
@@ -39,7 +39,7 @@ public class LengthPercentage(
3939
if (s.endsWith("%")) {
4040
try {
4141
val value = s.substring(0, s.length - 1).toFloat()
42-
if (value > 0f) {
42+
if (value >= 0f) {
4343
LengthPercentage(value, LengthPercentageType.PERCENT)
4444
} else {
4545
null

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

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,36 +107,40 @@ public data class BorderRadiusStyle(
107107
width: Float,
108108
height: Float,
109109
): ComputedBorderRadius {
110-
val topLeft: LengthPercentage? = startStart ?: topStart ?: topLeft ?: uniform
111-
val topRight: LengthPercentage? = endStart ?: topEnd ?: topRight ?: uniform
112-
val bottomLeft: LengthPercentage? = startEnd ?: bottomStart ?: bottomLeft ?: uniform
113-
val bottomRight: LengthPercentage? = endEnd ?: bottomEnd ?: bottomRight ?: uniform
114-
115110
return when (layoutDirection) {
116111
LayoutDirection.LTR ->
117112
ComputedBorderRadius(
118-
topLeft = topLeft?.resolve(width, height) ?: 0f,
119-
topRight = topRight?.resolve(width, height) ?: 0f,
120-
bottomLeft = bottomLeft?.resolve(width, height) ?: 0f,
121-
bottomRight = bottomRight?.resolve(width, height) ?: 0f,
113+
topLeft =
114+
(startStart ?: topStart ?: topLeft ?: uniform)?.resolve(width, height) ?: 0f,
115+
topRight = (endStart ?: topEnd ?: topRight ?: uniform)?.resolve(width, height) ?: 0f,
116+
bottomLeft =
117+
(startEnd ?: bottomStart ?: bottomLeft ?: uniform)?.resolve(width, height) ?: 0f,
118+
bottomRight =
119+
(endEnd ?: bottomEnd ?: bottomRight ?: uniform)?.resolve(width, height) ?: 0f,
122120
)
123121
LayoutDirection.RTL ->
124122
if (I18nUtil.instance.doLeftAndRightSwapInRTL(context)) {
125123
ComputedBorderRadius(
126-
topLeft = topRight?.resolve(width, height) ?: 0f,
127-
topRight = topLeft?.resolve(width, height) ?: 0f,
128-
bottomLeft = bottomRight?.resolve(width, height) ?: 0f,
129-
bottomRight = bottomLeft?.resolve(width, height) ?: 0f,
124+
topLeft = (endStart ?: topEnd ?: topRight ?: uniform)?.resolve(width, height) ?: 0f,
125+
topRight =
126+
(startStart ?: topStart ?: topLeft ?: uniform)?.resolve(width, height) ?: 0f,
127+
bottomLeft =
128+
(endEnd ?: bottomStart ?: bottomRight ?: uniform)?.resolve(width, height) ?: 0f,
129+
bottomRight =
130+
(startEnd ?: bottomEnd ?: bottomLeft ?: uniform)?.resolve(width, height) ?: 0f,
130131
)
131132
} else {
132133
ComputedBorderRadius(
133-
topLeft = topRight?.resolve(width, height) ?: 0f,
134-
topRight = topLeft?.resolve(width, height) ?: 0f,
135-
bottomLeft = bottomRight?.resolve(width, height) ?: 0f,
136-
bottomRight = bottomLeft?.resolve(width, height) ?: 0f,
134+
topLeft = (endStart ?: topEnd ?: topLeft ?: uniform)?.resolve(width, height) ?: 0f,
135+
topRight =
136+
(startStart ?: topStart ?: topRight ?: uniform)?.resolve(width, height) ?: 0f,
137+
bottomLeft =
138+
(endEnd ?: bottomStart ?: bottomLeft ?: uniform)?.resolve(width, height) ?: 0f,
139+
bottomRight =
140+
(startEnd ?: bottomEnd ?: bottomRight ?: uniform)?.resolve(width, height) ?: 0f,
137141
)
138142
}
139-
else -> throw IllegalArgumentException("Expected resolved layout direction")
143+
else -> throw IllegalArgumentException("Expected?.resolved layout direction")
140144
}
141145
}
142146
}

0 commit comments

Comments
 (0)