From 1d5103227851ab92de889d5e7e910393b5d8743a Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 16 Feb 2023 08:09:22 -0800 Subject: [PATCH] fix: border rendering problem in Android (#36129) Summary: Fixes https://github.com/facebook/react-native/issues/36036 The problem was in `ReactViewBackgroundDrawable.java` that was not accounting for adjacent borders that add width set to 0. ## Changelog [Android] [Fixed] - Fix border rendering issue when bottom borders has no width Pull Request resolved: https://github.com/facebook/react-native/pull/36129 Test Plan: | Previously | Now with the fix | | --------------- | --------------- | | image | image | Reviewed By: cipolleschi Differential Revision: D43303228 Pulled By: javache fbshipit-source-id: cf9d30fe12a5740d9ee8974a66904fd0850e7606 --- .../view/ReactViewBackgroundDrawable.java | 10 ++++- .../rn-tester/js/examples/View/ViewExample.js | 38 ++++++++++++++++++- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java index eded03ee94dfb0..dc54a6ff8a3465 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java @@ -911,7 +911,10 @@ private void updatePath() { } mInnerBottomLeftCorner.x = mInnerClipTempRectForBorderRadius.left; - mInnerBottomLeftCorner.y = mInnerClipTempRectForBorderRadius.bottom * -2; + mInnerBottomLeftCorner.y = + borderWidth.bottom != 0 + ? mInnerClipTempRectForBorderRadius.bottom * -2 + : mInnerClipTempRectForBorderRadius.bottom; getEllipseIntersectionWithLine( // Ellipse Bounds @@ -963,7 +966,10 @@ private void updatePath() { } mInnerBottomRightCorner.x = mInnerClipTempRectForBorderRadius.right; - mInnerBottomRightCorner.y = mInnerClipTempRectForBorderRadius.bottom * -2; + mInnerBottomRightCorner.y = + borderWidth.bottom != 0 + ? mInnerClipTempRectForBorderRadius.bottom * -2 + : mInnerClipTempRectForBorderRadius.bottom; getEllipseIntersectionWithLine( // Ellipse Bounds diff --git a/packages/rn-tester/js/examples/View/ViewExample.js b/packages/rn-tester/js/examples/View/ViewExample.js index 8602101cf521bd..58a20c7b20980a 100644 --- a/packages/rn-tester/js/examples/View/ViewExample.js +++ b/packages/rn-tester/js/examples/View/ViewExample.js @@ -431,7 +431,7 @@ exports.examples = [ title: 'Rounded Borders', render(): React.Node { return ( - + + + + + ); },