@@ -632,13 +632,10 @@ public void maybeSetText(ReactTextUpdate reactTextUpdate) {
632
632
if (reactTextUpdate .getText ().length () == 0 ) {
633
633
setText (null );
634
634
} else {
635
- boolean shouldRestoreComposingSpans = length () == spannableStringBuilder .length ();
636
-
635
+ // When we update text, we trigger onChangeText code that will
636
+ // try to update state if the wrapper is available. Temporarily disable
637
+ // to prevent an infinite loop.
637
638
getText ().replace (0 , length (), spannableStringBuilder );
638
-
639
- if (shouldRestoreComposingSpans ) {
640
- restoreComposingSpansToTextFrom (spannableStringBuilder );
641
- }
642
639
}
643
640
mDisableTextDiffing = false ;
644
641
@@ -653,13 +650,10 @@ public void maybeSetText(ReactTextUpdate reactTextUpdate) {
653
650
}
654
651
655
652
/**
656
- * Remove and/or add {@link Spanned#SPAN_EXCLUSIVE_EXCLUSIVE} spans, since they should only exist
657
- * as long as the text they cover is the same unless they are {@link Spanned#SPAN_COMPOSING}. All
658
- * other spans will remain the same, since they will adapt to the new text, hence why {@link
659
- * SpannableStringBuilder#replace} never removes them. Keep copy of {@link Spanned#SPAN_COMPOSING}
660
- * Spans in {@param spannableStringBuilder}, because they are important for keyboard suggestions.
661
- * Without keeping these Spans, suggestions default to be put after the current selection
662
- * position, possibly resulting in letter duplication.
653
+ * Remove and/or add {@link Spanned.SPAN_EXCLUSIVE_EXCLUSIVE} spans, since they should only exist
654
+ * as long as the text they cover is the same. All other spans will remain the same, since they
655
+ * will adapt to the new text, hence why {@link SpannableStringBuilder#replace} never removes
656
+ * them.
663
657
*/
664
658
private void manageSpans (SpannableStringBuilder spannableStringBuilder ) {
665
659
Object [] spans = getText ().getSpans (0 , length (), Object .class );
@@ -668,7 +662,6 @@ private void manageSpans(SpannableStringBuilder spannableStringBuilder) {
668
662
int spanFlags = getText ().getSpanFlags (span );
669
663
boolean isExclusiveExclusive =
670
664
(spanFlags & Spanned .SPAN_EXCLUSIVE_EXCLUSIVE ) == Spanned .SPAN_EXCLUSIVE_EXCLUSIVE ;
671
- boolean isComposing = (spanFlags & Spanned .SPAN_COMPOSING ) == Spanned .SPAN_COMPOSING ;
672
665
673
666
// Remove all styling spans we might have previously set
674
667
if (span instanceof ReactSpan ) {
@@ -683,12 +676,6 @@ private void manageSpans(SpannableStringBuilder spannableStringBuilder) {
683
676
final int spanStart = getText ().getSpanStart (span );
684
677
final int spanEnd = getText ().getSpanEnd (span );
685
678
686
- // We keep a copy of Composing spans
687
- if (isComposing ) {
688
- spannableStringBuilder .setSpan (span , spanStart , spanEnd , spanFlags );
689
- continue ;
690
- }
691
-
692
679
// Make sure the span is removed from existing text, otherwise the spans we set will be
693
680
// ignored or it will cover text that has changed.
694
681
getText ().removeSpan (span );
@@ -816,34 +803,6 @@ private void addSpansFromStyleAttributes(SpannableStringBuilder workingText) {
816
803
}
817
804
}
818
805
819
- /**
820
- * Attaches the {@link Spanned#SPAN_COMPOSING} from {@param spannableStringBuilder} to {@link
821
- * ReactEditText#getText}
822
- *
823
- * <p>See {@link ReactEditText#manageSpans} for more details. Also
824
- * https://github.com/facebook/react-native/issues/11068
825
- */
826
- private void restoreComposingSpansToTextFrom (SpannableStringBuilder spannableStringBuilder ) {
827
- Editable text = getText ();
828
- if (text == null ) {
829
- return ;
830
- }
831
- Object [] spans = spannableStringBuilder .getSpans (0 , length (), Object .class );
832
- for (Object span : spans ) {
833
- int spanFlags = spannableStringBuilder .getSpanFlags (span );
834
- boolean isComposing = (spanFlags & Spanned .SPAN_COMPOSING ) == Spanned .SPAN_COMPOSING ;
835
-
836
- if (!isComposing ) {
837
- continue ;
838
- }
839
-
840
- final int spanStart = spannableStringBuilder .getSpanStart (span );
841
- final int spanEnd = spannableStringBuilder .getSpanEnd (span );
842
-
843
- text .setSpan (span , spanStart , spanEnd , spanFlags );
844
- }
845
- }
846
-
847
806
private static boolean sameTextForSpan (
848
807
final Editable oldText ,
849
808
final SpannableStringBuilder newText ,
0 commit comments