mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Fix Android bottom logical border radii in RTL without swapping (#58979)
Summary: On Android, `BorderRadiusStyle.resolve` maps `borderBottomStartRadius` to the bottom-left corner and `borderBottomEndRadius` to the bottom-right corner when the layout direction is RTL and `I18nManager.swapLeftAndRightInRTL(false)` is set. In RTL, these logical properties should resolve to the bottom-right and bottom-left corners respectively, regardless of whether physical left/right styles are swapped. For example, a 100 x 100 view with `borderBottomStartRadius: 10` and `borderBottomEndRadius: 20` currently resolves to bottom-left = 10 and bottom-right = 20 in that configuration. This change resolves them to bottom-left = 20 and bottom-right = 10. Fix the two logical fallbacks in the RTL no-swap branch. Correct the corresponding expectations in `testCorrectPriorityRTLNoSwap`, which currently encode the same incorrect mapping, and add a regression test using distinct bottom-start and bottom-end radii with physical swapping both enabled and disabled. The existing priority tests also cover physical fallbacks, fully logical overrides, and zero-valued overrides. ## Changelog: [ANDROID] [FIXED] - Fix bottom-start and bottom-end border radii resolving to the wrong corners in RTL when left/right style swapping is disabled. Pull Request resolved: https://github.com/react/react-native/pull/58979 Test Plan: - `git diff --check`: passed before committing. - Kotlin formatting check using the repository-pinned ktfmt 0.59.0: passed for both changed files. Exact PowerShell command: ```powershell & 'C:/Program Files/JetBrains/RustRover 2026.2.2/jbr/bin/java.exe' -jar E:/react-native/.tools/format/node_modules/ktfmt/lib/ktfmt.jar --do-not-remove-unused-imports --dry-run --set-exit-if-changed packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/style/BorderRadiusStyle.kt packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BorderRadiusStyleTest.kt ``` - Attempted the targeted Android unit tests: ```powershell ./gradlew.bat :packages:react-native:ReactAndroid:testDebugUnitTest --tests com.facebook.react.uimanager.BorderRadiusStyleTest --no-daemon ``` The tests did not execute: the wrapper could not download Gradle 9.4.1 in the restricted environment (`Permission denied: getsockopt`). A retry outside the sandbox made no download progress and was stopped. The Android SDK/NDK is not configured on this machine. The unit tests still need to run in CI or an Android development environment. - RNTester/device validation and screenshots were not available in this environment. To validate visually, enable RTL, disable physical left/right swapping, restart the app, and render the 100 x 100 view described above. Expect the bottom-right radius to be 10 and the bottom-left radius to be 20; enabling swapping should preserve these logical corner assignments. Reviewed By: javache Differential Revision: D126298086 Pulled By: cortinico fbshipit-source-id: 7a621c9338100bf53d4d32262557d5b65ccead1a
This commit is contained in:
1 parent
a613baf9d1
commit
202d93931c
2 files changed
+21
-4
No files matched your search
+2
-2
@@ -208,11 +208,11 @@ internal data class BorderRadiusStyle(
|
||||
CornerRadii(it, width, height)
|
||||
} ?: zeroRadii,
|
||||
bottomLeft =
|
||||
(endEnd ?: bottomStart ?: bottomLeft ?: uniform)?.let {
|
||||
(endEnd ?: bottomEnd ?: bottomLeft ?: uniform)?.let {
|
||||
CornerRadii(it, width, height)
|
||||
} ?: zeroRadii,
|
||||
bottomRight =
|
||||
(endStart ?: bottomEnd ?: bottomRight ?: uniform)?.let {
|
||||
(endStart ?: bottomStart ?: bottomRight ?: uniform)?.let {
|
||||
CornerRadii(it, width, height)
|
||||
} ?: zeroRadii,
|
||||
width = width,
|
||||
|
||||
+19
-2
@@ -149,14 +149,14 @@ class BorderRadiusStyleTest {
|
||||
arrayOf(
|
||||
BorderRadiusProp.BORDER_RADIUS,
|
||||
BorderRadiusProp.BORDER_BOTTOM_LEFT_RADIUS,
|
||||
BorderRadiusProp.BORDER_BOTTOM_START_RADIUS,
|
||||
BorderRadiusProp.BORDER_BOTTOM_END_RADIUS,
|
||||
BorderRadiusProp.BORDER_END_END_RADIUS,
|
||||
),
|
||||
ComputedBorderRadiusProp.COMPUTED_BORDER_BOTTOM_RIGHT_RADIUS to
|
||||
arrayOf(
|
||||
BorderRadiusProp.BORDER_RADIUS,
|
||||
BorderRadiusProp.BORDER_BOTTOM_RIGHT_RADIUS,
|
||||
BorderRadiusProp.BORDER_BOTTOM_END_RADIUS,
|
||||
BorderRadiusProp.BORDER_BOTTOM_START_RADIUS,
|
||||
BorderRadiusProp.BORDER_END_START_RADIUS,
|
||||
),
|
||||
)
|
||||
@@ -174,6 +174,23 @@ class BorderRadiusStyleTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testBottomLogicalCornersRTLRegardlessOfSwap() {
|
||||
val borderRadiusStyle =
|
||||
BorderRadiusStyle(
|
||||
bottomStart = LengthPercentage(10f, LengthPercentageType.POINT),
|
||||
bottomEnd = LengthPercentage(20f, LengthPercentageType.POINT),
|
||||
)
|
||||
|
||||
for (swap in listOf(false, true)) {
|
||||
setContextLeftAndRightSwap(ctx, swap)
|
||||
val resolved = borderRadiusStyle.resolve(1, context = ctx, width = 100f, height = 100f)
|
||||
|
||||
assertThat(resolved.bottomLeft).isEqualTo(CornerRadii(20f, 20f))
|
||||
assertThat(resolved.bottomRight).isEqualTo(CornerRadii(10f, 10f))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testBorderRadiusPercentages() {
|
||||
val borderRadiusStyle =
|
||||
|
||||
Reference in new issue
Block a user