Skip to content

fix(android): crash when setting a percentage borderRadius on Text, TextInput, and ScrollView - #57869

Open
sbaiahmed1 wants to merge 1 commit into
react:mainfrom
sbaiahmed1:fix/percentage-border-radius-view-managers
Open

fix(android): crash when setting a percentage borderRadius on Text, TextInput, and ScrollView#57869
sbaiahmed1 wants to merge 1 commit into
react:mainfrom
sbaiahmed1:fix/percentage-border-radius-view-managers

Conversation

@sbaiahmed1

@sbaiahmed1 sbaiahmed1 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #57795, which fixed the percentage-borderRadius crash for <Image> (#53977). The same latent bug existed in every remaining Android view manager whose borderRadius @ReactPropGroup setter was still typed as Float:

  • ReactTextViewManager (<Text>)
  • PreparedLayoutTextViewManager (internal, prepared-layout <Text>)
  • ReactTextInputManager (<TextInput>)
  • ReactScrollViewManager (<ScrollView>)
  • ReactHorizontalScrollViewManager (<ScrollView horizontal>)
  • ReactNestedScrollViewManager (internal, nested-scroll variant)

Percentage border radii arrive from JS as strings ('50%'), so the reflection-based property updater throws:

com.facebook.react.bridge.JSApplicationIllegalArgumentException:
  Error while updating property 'borderRadius' of a view managed by: RCTText
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double

Each setter now accepts a Dynamic parsed with LengthPercentage.setFromDynamic, completing the migration ReactViewManager received in 0.75 and ReactImageManager in #57795. The Float overloads on the four public managers are kept as deprecated pass-throughs for source/binary compatibility (public API dump updated); the two internal managers are migrated outright. Rendering needs no changes since all six managers already delegate to BackgroundStyleApplicator, which resolves percentages.

Changelog:

[ANDROID] [FIXED] - Fix crash when setting a percentage borderRadius on Text, TextInput, and ScrollView

Test Plan

Unit tests — new Robolectric regression tests mirroring the one merged in #57795:

  • ReactTextViewPropertyTest.testBorderRadius (new file)
  • ReactTextInputPropertyTest.testBorderRadius

Both verified red before the fix (failing with JSApplicationIllegalArgumentException: Error while updating property 'borderRadius' of a view managed by: RCTText) and green after (:packages:react-native:ReactAndroid:testDebugUnitTest, 25/25 passing).

Manual QA — rn-tester on an Android emulator (API 35), rendering the snippet below with borderRadius: '50%' on <Text> and '20%' on <TextInput>, <ScrollView>, and <ScrollView horizontal>:

<Text style={{borderWidth: 2, borderColor: 'green', borderRadius: '50%', padding: 20}}>Text 50%</Text>
<TextInput style={{borderWidth: 2, borderColor: 'blue', borderRadius: '20%', padding: 12}} defaultValue="TextInput 20%" />
<ScrollView style={{borderWidth: 2, borderColor: 'purple', borderRadius: '20%', height: 80}}>...</ScrollView>
<ScrollView horizontal style={{borderWidth: 2, borderColor: 'purple', borderRadius: '20%', height: 80}}>...</ScrollView>

On main this screen crashes with the exception above; with this change all four render rounded corners.

Screenshots

Before (main) — surface fails to mount, exception above in logcat After (this PR) — all four components render their percentage radii

@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 Aug 9, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 9, 2026

@rachel11026725 rachel11026725 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix Android phone.

…and ScrollView (Android)

Percentage border radii arrive from JS as strings ('50%'), but the
borderRadius @ReactPropGroup setters in ReactTextViewManager,
PreparedLayoutTextViewManager, ReactTextInputManager,
ReactScrollViewManager, ReactHorizontalScrollViewManager, and
ReactNestedScrollViewManager still typed the prop as Float, so the
reflection-based property updater crashed with "java.lang.String cannot
be cast to java.lang.Double":

  JSApplicationIllegalArgumentException: Error while updating property
  'borderRadius' of a view managed by: RCTText

Accept a Dynamic and parse it with LengthPercentage.setFromDynamic,
completing the migration ReactViewManager received in 0.75 and
ReactImageManager in react#57795. The Float overloads on the public managers
are kept as deprecated pass-throughs for backward compatibility; the two
internal managers (PreparedLayoutTextViewManager,
ReactNestedScrollViewManager) are migrated outright.

Changelog:
[ANDROID] [FIXED] - Fix crash when setting a percentage borderRadius on Text, TextInput, and ScrollView
@sbaiahmed1

Copy link
Copy Markdown
Contributor Author

Fix Android phone.

I dont understand

@sbaiahmed1
sbaiahmed1 force-pushed the fix/percentage-border-radius-view-managers branch from e51dae8 to b69ad52 Compare August 9, 2026 12:36
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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants