Skip to content

Accept a numeric fontWeight in the Android TextInput native code - #60136

Merged
meta-codesync[bot] merged 1 commit into
mainfrom
textinput-font-weight-cpp
Nov 19, 2026
Merged

meta-codesync[bot] merged 1 commit into
mainfrom
textinput-font-weight-cpp

Conversation

@intergalacticspacehighway

@intergalacticspacehighway intergalacticspacehighway commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary:

On Android, TextInput keeps fontWeight as a string. So TextInput.js changes a numeric fontWeight (for example 700) to a string before it sends the props. The commit that added this (15f27bc) calls it "a quick and dirty replication" of the Text.js logic, to fix later for Fabric.

This PR makes the native code accept a number too:

  • C++ (AndroidTextInputProps): a number becomes a string, in the classic parser and in the iterator setter.
  • Kotlin (ReactTextInputManager.setFontWeight): the setter takes a Dynamic, so the raw props path also accepts a number. This changes the public signature from String? to Dynamic.

The JS conversion stays, so a new JS bundle still works with an older native build. A follow-up PR removes it after this change ships.

This also makes a numeric fontWeight work in a conditional style value (RFC, #60124), because the JS conversion cannot see inside one.

Changelog:

[ANDROID] [CHANGED] - TextInput accepts a numeric fontWeight in native code.

Test Plan:

  • New Kotlin test: ReactTextInputPropertyTest.testFontWeightAcceptsANumber.
  • RNTester on the Android emulator, with the JS conversion removed locally so the number reaches native: a TextInput with a numeric fontWeight renders with no errors in each combination of the props flags (Props 1.5, Props 2.0, exclusive props updates, the C++ iterator setter).
  • ./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests ReactTextInputPropertyTest: pass.

@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
@intergalacticspacehighway
intergalacticspacehighway force-pushed the textinput-font-weight-cpp branch 2 times, most recently from 652baa9 to 354f5a3 Compare November 19, 2026 05:15
@intergalacticspacehighway
intergalacticspacehighway marked this pull request as ready for review November 19, 2026 05:17
@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 Nov 19, 2026
@intergalacticspacehighway intergalacticspacehighway added p: Expo Partner: Expo and removed Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Nov 19, 2026

@javache javache left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We'll want to split this in two changes to remain backwards compatible with older native release, one for the native capability to parse both variants, and one with the JS changes.

@intergalacticspacehighway intergalacticspacehighway changed the title Move the TextInput fontWeight number conversion from JS to native Accept a numeric fontWeight in the Android TextInput native code Nov 19, 2026
@intergalacticspacehighway

intergalacticspacehighway commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator Author

Done. @javache Removed the JS change in this one. Follow up PR which can land later.

@meta-codesync

meta-codesync Bot commented Nov 19, 2026

Copy link
Copy Markdown

@javache has imported this pull request. If you are a Meta employee, you can view this in D133209822.

@meta-codesync
meta-codesync Bot merged commit 3d55ca9 into main Nov 19, 2026
102 checks passed
@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @intergalacticspacehighway in 3d55ca9

When will my fix make it into a release? | How to file a pick request?

@react-native-bot react-native-bot added the Merged This PR has been merged. label Nov 19, 2026
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. Merged This PR has been merged. p: Expo Partner: Expo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants