Skip to content

Fix text shadow on TextInput on Android when backgroundColor is set#45343

Closed
j-piasecki wants to merge 1 commit into
facebook:mainfrom
j-piasecki:@jpiasecki/fix-android-text-shadow-background
Closed

Fix text shadow on TextInput on Android when backgroundColor is set#45343
j-piasecki wants to merge 1 commit into
facebook:mainfrom
j-piasecki:@jpiasecki/fix-android-text-shadow-background

Conversation

@j-piasecki
Copy link
Copy Markdown
Contributor

Summary:

When setting a shadow on a Text inside a TextInput, the shadow was rendered with artifacts when backgroundColor was set on the TextInput.

This is caused by how attributed strings are constructed on the new architecture - all text attributes from the text input (including background color) are propagated onto the string. Then, it's converted to a Spannable on Android side, which includes ReactBackgroundColorSpan being set on the entire text when it doesn't have a background color set explicitly. Then Android tries to render the shadow not only for the text but also for the background rect which results in the artifacts.

This PR prevents background color from the TextInput from being propagated onto the attributed string, so the ReactBackgroundColorSpan is only applied when a text fragment has its background set explicitly.

Changelog:

[ANDROID] [FIXED] - Fixed text shadow rendering with artifacts when backgroundColor was set on the TextInput

Test Plan:

Checked relevant examples on RNTester

Old arch New arch (before) New arch (after)
Screenshot 2024-07-09 at 14 44 52 Screenshot 2024-07-09 at 14 43 03 Screenshot 2024-07-09 at 14 41 46

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Software Mansion Partner: Software Mansion Partner labels Jul 9, 2024
@cortinico
Copy link
Copy Markdown
Contributor

/rebase

@github-actions github-actions Bot force-pushed the @jpiasecki/fix-android-text-shadow-background branch from 66b469a to b22bd53 Compare July 9, 2024 13:21
@analysis-bot
Copy link
Copy Markdown

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 21,300,844 +16,705
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 24,497,590 +16,425
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 12b64b7
Branch: main

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@cortinico cortinico marked this pull request as ready for review July 10, 2024 10:05
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jul 10, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@cortinico merged this pull request in 8371629.

@github-actions
Copy link
Copy Markdown

This pull request was successfully merged by @j-piasecki in 8371629.

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

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: Software Mansion Partner: Software Mansion Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants