Fix TextInput text color not applying
Summary: Setting the color for a TextInput with nodes was broken. The text color was not being applied due to an optimization that prevented setting spans if begin and end were the same (which is the case for an empty TextInput). This patch depends on D2962643. Differential Revision: D2962394
This commit is contained in:
parent
b4100ef246
commit
827989f572
|
@ -52,12 +52,24 @@ import com.facebook.react.uimanager.ReactShadowNode;
|
||||||
mTextEnd = builder.length();
|
mTextEnd = builder.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not to allow empty spans to be set
|
||||||
|
* This is used to bypass an optimization in {@code applySpans} that skips applying spans if
|
||||||
|
* there is no text (since, for TextInput, for example, we want to apply the span even if there
|
||||||
|
* is no text so that newly typed text gets styled properly).
|
||||||
|
*
|
||||||
|
* @return a boolean representing whether or not we should allow empty spans
|
||||||
|
*/
|
||||||
|
/* package */ boolean shouldAllowEmptySpans() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively visits FlatTextShadowNode and its children,
|
* Recursively visits FlatTextShadowNode and its children,
|
||||||
* applying spans to SpannableStringBuilder.
|
* applying spans to SpannableStringBuilder.
|
||||||
*/
|
*/
|
||||||
/* package */ final void applySpans(SpannableStringBuilder builder) {
|
/* package */ final void applySpans(SpannableStringBuilder builder) {
|
||||||
if (mTextBegin != mTextEnd) {
|
if (mTextBegin != mTextEnd || shouldAllowEmptySpans()) {
|
||||||
performApplySpans(builder, mTextBegin, mTextEnd);
|
performApplySpans(builder, mTextBegin, mTextEnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,11 @@ public class RCTTextInput extends RCTVirtualText implements AndroidView, CSSNode
|
||||||
mPaddingChanged = false;
|
mPaddingChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean shouldAllowEmptySpans() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new CharSequence that includes all the text and styling information to create Layout.
|
* Returns a new CharSequence that includes all the text and styling information to create Layout.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue