Skip to content

Commit

Permalink
Fix elevation with border-radius set (#48982)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #48982

We were missing a conversion to px on the `getOutline()` function of `CompositeBackgroundDrawable` which led to incorrect elevation prop rendering

Changelog: [Android][Fixed] - Elevation prop on android has incorrect border-radius

Reviewed By: NickGerleman

Differential Revision: D68724947

fbshipit-source-id: b3a7a4919bfd7c60fac7c3d6e3ba760e3f74d190
  • Loading branch information
jorge-cab authored and robhogan committed Feb 11, 2025
1 parent bc35afe commit 55d5c44
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import android.graphics.drawable.LayerDrawable
import android.os.Build
import com.facebook.react.common.annotations.UnstableReactNativeAPI
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
import com.facebook.react.uimanager.PixelUtil.dpToPx
import com.facebook.react.uimanager.style.BorderInsets
import com.facebook.react.uimanager.style.BorderRadiusStyle

Expand Down Expand Up @@ -200,14 +201,14 @@ internal class CompositeBackgroundDrawable(
pathForOutline.addRoundRect(
RectF(bounds),
floatArrayOf(
it.topLeft.horizontal + (computedBorderInsets?.left ?: 0f),
it.topLeft.vertical + (computedBorderInsets?.top ?: 0f),
it.topRight.horizontal + (computedBorderInsets?.right ?: 0f),
it.topRight.vertical + (computedBorderInsets?.top ?: 0f),
it.bottomRight.horizontal + (computedBorderInsets?.right ?: 0f),
it.bottomRight.vertical + (computedBorderInsets?.bottom ?: 0f),
it.bottomLeft.horizontal + (computedBorderInsets?.left ?: 0f),
it.bottomLeft.vertical) + (computedBorderInsets?.bottom ?: 0f),
(it.topLeft.horizontal + (computedBorderInsets?.left ?: 0f)).dpToPx(),
(it.topLeft.vertical + (computedBorderInsets?.top ?: 0f)).dpToPx(),
(it.topRight.horizontal + (computedBorderInsets?.right ?: 0f)).dpToPx(),
(it.topRight.vertical + (computedBorderInsets?.top ?: 0f)).dpToPx(),
(it.bottomRight.horizontal + (computedBorderInsets?.right ?: 0f)).dpToPx(),
(it.bottomRight.vertical + (computedBorderInsets?.bottom ?: 0f)).dpToPx(),
(it.bottomLeft.horizontal + (computedBorderInsets?.left ?: 0f)).dpToPx(),
(it.bottomLeft.vertical + (computedBorderInsets?.bottom ?: 0f)).dpToPx()),
Path.Direction.CW)
}

Expand Down

0 comments on commit 55d5c44

Please sign in to comment.