Skip to content

Update border geometry when layout direction changes on Android - #60161

Open
jasozh wants to merge 3 commits into
react:mainfrom
jasozh:export-D132253217
Open

jasozh wants to merge 3 commits into
react:mainfrom
jasozh:export-D132253217

Conversation

@jasozh

@jasozh jasozh commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Summary:
Fixes an issue where border radius on drawables is not updated when the direction style changes on Android.

Root Cause

Background, border, and background image drawables cache paths built from the resolved border radii and widths. When a mounted view's layout direction changed by toggling the direction style, logical values such as borderTopStartRadius kept their previous physical corners and edges. The view's outline, used for the elevation shadow, had the same problem.

This PR

Override onLayoutDirectionChanged() to add invalidateSelf() for BackgroundDrawwable, BackgroundImageDrawable, BorderDrawable, and CompositeBackgroundDrawable.

Changelog: [Android][Fixed] - Fix logical border radii and widths not updating when a view's layout direction changes at runtime

Differential Revision: D132253217

Summary:

Fixes [react#34553](react#34553), where the ripple effect is a square even if the underlying Pressable is rounded.

### Root Cause

For bounded ripples, ReactDrawableHelper creates a RippleDrawable with a ColorDrawable mask. This mask is rectangular and remains that way when added to CompositeBackgroundDrawable as a feedback layer, even if a border radius is configured.

### This PR

Modify ReactDrawableHelper to replace the RippleDrawable's rectangular ColorDrawable mask with a BackgroundDrawable. If border radius is set, `getOpacity()` returns `PixelFormat.TRANSLUCENT` which makes RippleDrawable draw the mask into an alpha-only bitmap so the ripple respects the border radius. Otherwise, it returns `PixelFormat.OPAQUE` to avoid the cost of creating the bitmap and match the original ColorDrawable behavior.

Modify BackgroundStyleApplicator to update the ripple mask's border radius during `setFeedbackUnderlay()`, `setFeedbackOverlay()`, and `setBorderRadius()`. Also make `ReactViewGroup.applyNativeForeground()` call `setFeedbackOverlay()` so that foreground ripples are properly clipped.

Changelog: [Android][Fixed] - Fix Pressable ripple leaking past rounded corners

Reviewed By: cortinico

Differential Revision: D123816883
Summary:

Add a new RNTester example in RTLExample that reproduces the issue where toggling the direction style fails to update border radius on Android.

Changelog: [Internal]

Differential Revision: D132253189
Summary:
Fixes an issue where border radius on drawables is not updated when the direction style changes on Android.

### Root Cause

Background, border, and background image drawables cache paths built from the resolved border radii and widths. When a mounted view's layout direction changed by toggling the `direction` style, logical values such as `borderTopStartRadius` kept their previous physical corners and edges. The view's outline, used for the `elevation` shadow, had the same problem.

### This PR

Override `onLayoutDirectionChanged()` to add `invalidateSelf()` for BackgroundDrawwable, BackgroundImageDrawable, BorderDrawable, and CompositeBackgroundDrawable.

Changelog: [Android][Fixed] - Fix logical border radii and widths not updating when a view's layout direction changes at runtime

Differential Revision: D132253217
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 19, 2026
@meta-codesync

meta-codesync Bot commented Nov 19, 2026

Copy link
Copy Markdown

@jasozh has exported this pull request. If you are a Meta employee, you can view the originating Diff in D132253217.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant