mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
4622532ca4
Summary: The TextInput spannables are being set wrong by Nodes. Consequently, when you hit space after a word, anything you type is highlighted, though it shouldn't be. Differential Revision: D3507516
57 lines
1.3 KiB
Java
57 lines
1.3 KiB
Java
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
package com.facebook.react.flat;
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
import android.text.Spannable;
|
|
import android.text.SpannableStringBuilder;
|
|
|
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
|
|
/**
|
|
* RCTRawText is a FlatTextShadowNode that can only contain raw text (but not styling).
|
|
*/
|
|
/* package */ final class RCTRawText extends FlatTextShadowNode {
|
|
|
|
private @Nullable String mText;
|
|
|
|
@Override
|
|
protected void performCollectText(SpannableStringBuilder builder) {
|
|
if (mText != null) {
|
|
builder.append(mText);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void performApplySpans(
|
|
SpannableStringBuilder builder,
|
|
int begin,
|
|
int end,
|
|
boolean isEditable) {
|
|
builder.setSpan(
|
|
this,
|
|
begin,
|
|
end,
|
|
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
|
}
|
|
|
|
@Override
|
|
protected void performCollectAttachDetachListeners(StateBuilder stateBuilder) {
|
|
// nothing to do
|
|
}
|
|
|
|
@ReactProp(name = "text")
|
|
public void setText(@Nullable String text) {
|
|
mText = text;
|
|
notifyChanged(true);
|
|
}
|
|
}
|