Skip to content

Fix TextInput boxShadow disappearing or taking the underlineColorAndroid color on Android - #60305

Open
LouisHaftmann wants to merge 1 commit into
react:mainfrom
LouisHaftmann:fix/textinput-underline-color-box-shadow
Open

LouisHaftmann wants to merge 1 commit into
react:mainfrom
LouisHaftmann:fix/textinput-underline-color-box-shadow

Conversation

@LouisHaftmann

Copy link
Copy Markdown

Summary:

Fixes #60303. Probably also the cause of #47920.

On Android, a TextInput with boxShadow loses its shadow, or gets it tinted, depending on the order its props are applied.

ReactTextInputManager.setUnderlineColor applies underlineColorAndroid as a SRC_IN color filter on view.background. Once the input has a boxShadow, outline, border or background color, BackgroundStyleApplicator has replaced that background with a CompositeBackgroundDrawable, so the filter goes to every layer of the composite, including the OutsetBoxShadowDrawables. TextInput defaults underlineColorAndroid to 'transparent', so:

  • If setBoxShadow runs after setUnderlineColor, withNewShadows creates fresh shadow drawables without the filter, and the shadow shows.
  • If setUnderlineColor runs after setBoxShadow (prop order on mount, or any later change of underlineColorAndroid), the shadow is painted transparent, or in the underline color.

That is why the bug looks random in apps and did not reproduce in RNTester in #47920.

With this change, setUnderlineColor tints only the EditText's own background: CompositeBackgroundDrawable.originalBackground when the background is wrapped, the background itself otherwise. Every withNew* copy of the composite keeps the same originalBackground instance, so the underline color also survives when the composite is rebuilt later. This is the same approach as ReactSwitch in #59425.

Changelog:

[ANDROID] [FIXED] - Fix TextInput boxShadow disappearing or taking the underlineColorAndroid color

Test Plan:

Unit tests. New ReactTextInputUnderlineColorTest (Robolectric, native graphics) draws the background of a ReactEditText with a black box shadow:

  • underlineColorSetAfterBoxShadowKeepsTheShadow: the underline color is applied after the box shadow. It fails on main (expected:<-16777216> but was:<0>: the shadow pixel is transparent instead of black) and passes with this change.
  • underlineColorSetBeforeBoxShadowStaysOnTheUnderline: an underline color set before the box shadow stays on the underline after the composite wraps it, and clearing it removes it. This passes on main too, and guards the existing behavior.
./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests 'com.facebook.react.views.textinput.*'

44 tests in com.facebook.react.views.textinput, 0 failures. The full ./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest run: 1014 tests, 0 failures. yarn format-check-kotlin, eslint, prettier --check and flow check pass.

RNTester example and visual test. Added a boxShadow and underlineColorAndroid example (TextInputExample/boxShadowUnderlineColor) and an Android-only step in visual-tests/flows/text-input.yml that taps it to red and back to transparent and captures text-input/box-shadow-underline-color/red and .../transparent. Ran the TextInput flow with Maestro 2.6.1 on RNTester built with this change:

maestro test -e APP_ID=com.facebook.react.uiapp -e VISUAL_OUTPUT_DIR=/tmp/visual packages/rn-tester/visual-tests/flows/text-input.yml

It passes, and both new captures show the black shadow. The existing TextInput captures are unchanged.

Device. OnePlus 7 Pro (GM1913, Android 12), RNTester debug built from source, New Architecture, with the new example. Left to right: on mount, after tapping to red, after tapping back to transparent. The device is in dark mode, which is why the label row is black.

Before (main): the shadow turns red, then disappears.

Before

After: the shadow stays black.

After

The same before behavior on RN 0.88.1 is in the reproducer from the issue: https://github.com/LouisHaftmann/rn-textinput-boxshadow-underline

Not run: iOS (not affected, the change is Android only).

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@meta-cla

meta-cla Bot commented Nov 26, 2026

Copy link
Copy Markdown

Hi @LouisHaftmann!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Nov 26, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@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 26, 2026
@meta-cla

meta-cla Bot commented Nov 26, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@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 26, 2026
@meta-codesync

meta-codesync Bot commented Nov 30, 2026

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

Visual regression

2 visual difference(s) at 5f753470c72f. Visual differences need maintainer approval. Review the report, then apply visual-change-approved.

android text-input/box-shadow-underline-color/red: New

Captured
Captured
captured

android text-input/box-shadow-underline-color/transparent: New

Captured
Captured
captured

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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. visual-change-approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] TextInput: boxShadow disappears because the underlineColorAndroid color filter also tints it

2 participants