Repository navigation
Fix TextInput boxShadow disappearing or taking the underlineColorAndroid color on Android - #60305
LouisHaftmann wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Hi @LouisHaftmann! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this in D135141522. |
Visual regression2 visual difference(s) at android
|


Summary:
Fixes #60303. Probably also the cause of #47920.
On Android, a
TextInputwithboxShadowloses its shadow, or gets it tinted, depending on the order its props are applied.ReactTextInputManager.setUnderlineColorappliesunderlineColorAndroidas aSRC_INcolor filter onview.background. Once the input has aboxShadow, outline, border or background color,BackgroundStyleApplicatorhas replaced that background with aCompositeBackgroundDrawable, so the filter goes to every layer of the composite, including theOutsetBoxShadowDrawables.TextInputdefaultsunderlineColorAndroidto'transparent', so:setBoxShadowruns aftersetUnderlineColor,withNewShadowscreates fresh shadow drawables without the filter, and the shadow shows.setUnderlineColorruns aftersetBoxShadow(prop order on mount, or any later change ofunderlineColorAndroid), 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,
setUnderlineColortints only the EditText's own background:CompositeBackgroundDrawable.originalBackgroundwhen the background is wrapped, the background itself otherwise. EverywithNew*copy of the composite keeps the sameoriginalBackgroundinstance, so the underline color also survives when the composite is rebuilt later. This is the same approach asReactSwitchin #59425.Changelog:
[ANDROID] [FIXED] - Fix
TextInputboxShadowdisappearing or taking theunderlineColorAndroidcolorTest Plan:
Unit tests. New
ReactTextInputUnderlineColorTest(Robolectric, native graphics) draws the background of aReactEditTextwith a black box shadow:underlineColorSetAfterBoxShadowKeepsTheShadow: the underline color is applied after the box shadow. It fails onmain(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 onmaintoo, and guards the existing behavior.44 tests in
com.facebook.react.views.textinput, 0 failures. The full./gradlew :packages:react-native:ReactAndroid:testDebugUnitTestrun: 1014 tests, 0 failures.yarn format-check-kotlin,eslint,prettier --checkandflow checkpass.RNTester example and visual test. Added a
boxShadow and underlineColorAndroidexample (TextInputExample/boxShadowUnderlineColor) and an Android-only step invisual-tests/flows/text-input.ymlthat taps it toredand back totransparentand capturestext-input/box-shadow-underline-color/redand.../transparent. Ran the TextInput flow with Maestro 2.6.1 on RNTester built with this change: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 totransparent. The device is in dark mode, which is why the label row is black.Before (
main): the shadow turns red, then disappears.After: the shadow stays black.
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