Fix TextInput example with text attribute and child Text node: text background shouldn't be same as TextInput background

Summary:
Currently the TextInput background is same as the background of the `text` value's attributes, because of the way we're parsing props and using the TextInput's props both for the background of the TextInput, and for the AttributedString/background color of the `text` prop node's attributes. If the background color has opacity, the `text` prop node will not have the correct background because it will be applied twice. Fix it.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18760384

fbshipit-source-id: 0cdcc8dd8839dd47e8fe0f593b4696bc16a62333
This commit is contained in:
Joshua Gross
2019-12-05 13:20:29 -08:00
committed by Facebook Github Bot
parent a09346f129
commit 25ce622683
@@ -45,6 +45,10 @@ AttributedString AndroidTextInputShadowNode::getAttributedString(
auto fragment = AttributedString::Fragment{};
fragment.string = getProps()->text;
fragment.textAttributes = textAttributes;
// If the TextInput opacity is 0 < n < 1, the opacity of the TextInput and
// text value's background will stack. This is a hack/workaround to prevent
// that effect.
fragment.textAttributes.backgroundColor = clearColor();
fragment.parentShadowView = ShadowView(*this);
attributedString.prependFragment(fragment);