Skip to content

Commit e441f05

Browse files
committed
Fix Android bottom logical border radii in RTL without swapping
1 parent 1c6e0c7 commit e441f05

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ internal data class BorderRadiusStyle(
208208
CornerRadii(it, width, height)
209209
} ?: zeroRadii,
210210
bottomLeft =
211-
(endEnd ?: bottomStart ?: bottomLeft ?: uniform)?.let {
211+
(endEnd ?: bottomEnd ?: bottomLeft ?: uniform)?.let {
212212
CornerRadii(it, width, height)
213213
} ?: zeroRadii,
214214
bottomRight =
215-
(endStart ?: bottomEnd ?: bottomRight ?: uniform)?.let {
215+
(endStart ?: bottomStart ?: bottomRight ?: uniform)?.let {
216216
CornerRadii(it, width, height)
217217
} ?: zeroRadii,
218218
width = width,

‎packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BorderRadiusStyleTest.kt‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,14 @@ class BorderRadiusStyleTest {
149149
arrayOf(
150150
BorderRadiusProp.BORDER_RADIUS,
151151
BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS,
152-
BorderRadiusProp.BORDER_BOTTOM_START_RADIUS,
152+
BorderRadiusProp.BORDER_BOTTOM_END_RADIUS,
153153
BorderRadiusProp.BORDER_END_END_RADIUS,
154154
),
155155
ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_RIGHT_RADIUS to
156156
arrayOf(
157157
BorderRadiusProp.BORDER_RADIUS,
158158
BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS,
159-
BorderRadiusProp.BORDER_BOTTOM_END_RADIUS,
159+
BorderRadiusProp.BORDER_BOTTOM_START_RADIUS,
160160
BorderRadiusProp.BORDER_END_START_RADIUS,
161161
),
162162
)
@@ -174,6 +174,23 @@ class BorderRadiusStyleTest {
174174
}
175175
}
176176

177+
@Test
178+
fun testBottomLogicalCornersRTLRegardlessOfSwap() {
179+
val borderRadiusStyle =
180+
BorderRadiusStyle(
181+
bottomStart = LengthPercentage(10f, LengthPercentageType.POINT),
182+
bottomEnd = LengthPercentage(20f, LengthPercentageType.POINT),
183+
)
184+
185+
for (swap in listOf(false, true)) {
186+
setContextLeftAndRightSwap(ctx, swap)
187+
val resolved = borderRadiusStyle.resolve(1, context = ctx, width = 100f, height = 100f)
188+
189+
assertThat(resolved.bottomLeft).isEqualTo(CornerRadii(20f, 20f))
190+
assertThat(resolved.bottomRight).isEqualTo(CornerRadii(10f, 10f))
191+
}
192+
}
193+
177194
@Test
178195
fun testBorderRadiusPercentages() {
179196
val borderRadiusStyle =

0 commit comments

Comments
 (0)