Fix spannable flags in RCTVirtualText
Summary: The spannable flags for RCTVirtualText were always being set to INCLUSIVE_EXCLUSIVE - this is different than the behavior that is found in ReactTextShadowNode, which sets EXCLUSIVE_INCLUSIVE as the default flag unless the text is at the beginning. This is needed to fix various problems with TextInput, including the handling of empty spans (see also D2962394 which depends on this patch), and making the behavior consistent when styled children of a TextInput are changed. Differential Revision: D2962643
This commit is contained in:
parent
055b31a165
commit
b4100ef246
|
@ -50,11 +50,17 @@ import com.facebook.react.uimanager.ViewProps;
|
||||||
protected void performApplySpans(SpannableStringBuilder builder, int begin, int end) {
|
protected void performApplySpans(SpannableStringBuilder builder, int begin, int end) {
|
||||||
mFontStylingSpan.freeze();
|
mFontStylingSpan.freeze();
|
||||||
|
|
||||||
|
// All spans will automatically extend to the right of the text, but not the left - except
|
||||||
|
// for spans that start at the beginning of the text.
|
||||||
|
final int flag = begin == 0 ?
|
||||||
|
Spannable.SPAN_INCLUSIVE_INCLUSIVE :
|
||||||
|
Spannable.SPAN_EXCLUSIVE_INCLUSIVE;
|
||||||
|
|
||||||
builder.setSpan(
|
builder.setSpan(
|
||||||
mFontStylingSpan,
|
mFontStylingSpan,
|
||||||
begin,
|
begin,
|
||||||
end,
|
end,
|
||||||
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
flag);
|
||||||
|
|
||||||
if (mShadowStyleSpan.getColor() != 0 && mShadowStyleSpan.getRadius() != 0) {
|
if (mShadowStyleSpan.getColor() != 0 && mShadowStyleSpan.getRadius() != 0) {
|
||||||
mShadowStyleSpan.freeze();
|
mShadowStyleSpan.freeze();
|
||||||
|
@ -63,7 +69,7 @@ import com.facebook.react.uimanager.ViewProps;
|
||||||
mShadowStyleSpan,
|
mShadowStyleSpan,
|
||||||
begin,
|
begin,
|
||||||
end,
|
end,
|
||||||
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, childCount = getChildCount(); i < childCount; ++i) {
|
for (int i = 0, childCount = getChildCount(); i < childCount; ++i) {
|
||||||
|
|
Loading…
Reference in New Issue